Home Manual Reference Source Test Repository
public class | source

ModuleReport

Extends:

AbstractReport → ModuleReport

Provides the module report object which stores data pertaining to a single file / module being processed.

All ES Module classes are stored in the classes member variable as ClassReports. Methods that are not part of a class are stored as ModuleMethodReport instances in the methods member variable.

Various helper methods found in ModuleReport and AbstractReport help increment associated data during collection.

Static Method Summary

Static Public Methods
public static

Returns the supported transform formats.

public static

Deserializes a JSON object representing a ModuleReport.

Constructor Summary

Public Constructor
public

constructor(lineStart: number, lineEnd: number, settings: object)

Initializes the report.

Member Summary

Public Members
public

Stores all ClassReport data for the module.

public

Stores all parsed dependencies.

public

Stores any analysis errors.

public

Stores the file path of the module / file.

public

Stores the end line for the module / file.

public

Stores the start line for the module / file.

public

Measures the average method maintainability index for the module / file.

public

Stores the average method metric data.

public

Stores all module ModuleMethodReport data found outside of any ES6 classes.

public

Stores the settings used to generate the module report.

public

Stores the active source path of the module / file.

public

Stores the active source path alias of the module / file.

public get

Returns the enum for the report type.

Private Members
private

Stores the current class report scope stack which is lazily created in createScope.

private

_scopeStackMethod: Array<ClassMethodReport | ModuleMethodReport>

Stores the current method report scope stack which is lazily created in createScope.

Method Summary

Public Methods
public

addDependencies(dependencies: object | Array)

Potentially adds given dependencies for tracking.

public

clearErrors(clearChildren: boolean)

Clears all errors stored in the module report and by default any class reports and module methods.

public

createScope(type: string, name: string, lineStart: number, lineEnd: number, params: number): object

Creates a report scope when a class or method is entered.

public

Cleans up any house keeping member variables.

public

Returns the current class report.

public

Returns the current method report.

public

getErrors(options: object): Array<AnalyzeError | {error: AnalyzeError, source: *}>

Gets all errors stored in the module report and by default any module methods and class reports.

public

Returns the name / id associated with this report.

public

getSetting(key: string, defaultValue: *): *

Returns the setting indexed by the given key.

public

halsteadItemEncountered(metric: string, identifier: string)

Increments the Halstead metric for the given identifier for the ModuleReport and any current class or method report being tracked.

public

Increments the cyclomatic metric for the ModuleReport and any current class or method report being tracked.

public

Increments the logical SLOC (source lines of code) metric for the ModuleReport and any current class or method report being tracked.

public

popScope(type: string): *

Pops a report scope.

public

processHalsteadItems(metric: string, identifiers: Array<string>)

Processes all TraitHalstead identifier data.

public

setSetting(key: string, value: *): boolean

Sets the setting indexed by the given key and returns true if successful.

Inherited Summary

From class AbstractReport
public get

Returns the associated AggregateMethodReport or this.

public

Stores any associated AggregateMethodReport.

public

Increments the associated aggregate report HalsteadData for distinct identifiers.

public

incrementHalsteadItems(metric: string, identifier: string)

Increments the associated aggregate report Halstead items including distinct and total counts.

public

Increments the associated aggregate report Halstead metric type.

public

Increments the associated aggregate report parameter count.

public

Returns true if a given HalsteadData metric / identifier is not found in the associated aggregate report.

public

toFormat(name: string, options: object): string

Formats this report given the type.

Static Public Methods

public static getFormats(): Object[] source

Returns the supported transform formats.

Return:

Object[]

public static parse(object: object): ModuleReport source

Deserializes a JSON object representing a ModuleReport.

Params:

NameTypeAttributeDescription
object object

A JSON object of a ModuleReport that was previously serialized.

Return:

ModuleReport

Public Constructors

public constructor(lineStart: number, lineEnd: number, settings: object) source

Initializes the report.

Override:

AbstractReport#constructor

Params:

NameTypeAttributeDescription
lineStart number

Start line of file / module.

lineEnd number

End line of file / module.

settings object

An object hash of the settings used in generating this report via ESComplexModule.

Public Members

public classes: Array<ClassReport> source

Stores all ClassReport data for the module.

public dependencies: Array source

Stores all parsed dependencies.

public errors: Array source

Stores any analysis errors.

public filePath: string source

Stores the file path of the module / file. The file path is only defined as supplied when processing projects.

public lineEnd: number source

Stores the end line for the module / file.

public lineStart: number source

Stores the start line for the module / file.

public maintainability: number source

Measures the average method maintainability index for the module / file.

public methodAverage: MethodAverage source

Stores the average method metric data.

public methods: Array<ModuleMethodReport> source

Stores all module ModuleMethodReport data found outside of any ES6 classes.

public settings: object source

Stores the settings used to generate the module report.

public srcPath: string source

Stores the active source path of the module / file. This path is respective of how the file is referenced in the source code itself. srcPath is only defined as supplied when processing projects.

public srcPathAlias: string source

Stores the active source path alias of the module / file. This path is respective of how the file is referenced in the source code itself when aliased including NPM and JSPM modules which provide a main entry. srcPathAlias is only defined as supplied when processing projects.

public get type: ReportType: * source

Returns the enum for the report type.

Return:

ReportType

Private Members

private _scopeStackClass: Array<ClassReport> source

Stores the current class report scope stack which is lazily created in createScope.

private _scopeStackMethod: Array<ClassMethodReport | ModuleMethodReport> source

Stores the current method report scope stack which is lazily created in createScope.

Public Methods

public addDependencies(dependencies: object | Array) source

Potentially adds given dependencies for tracking.

Params:

NameTypeAttributeDescription
dependencies object | Array

Dependencies to add.

public clearErrors(clearChildren: boolean) source

Clears all errors stored in the module report and by default any class reports and module methods.

Params:

NameTypeAttributeDescription
clearChildren boolean

(Optional) If false then class and module method errors are not cleared; default (true).

public createScope(type: string, name: string, lineStart: number, lineEnd: number, params: number): object source

Creates a report scope when a class or method is entered.

Params:

NameTypeAttributeDescription
type string

Type of report to create.

name string

Name of the class or method.

lineStart number

Start line of method.

lineEnd number

End line of method.

params number

Number of parameters for method.

Return:

object

public finalize(): ModuleReport source

Cleans up any house keeping member variables.

Return:

ModuleReport

public getCurrentClassReport(): ClassReport source

Returns the current class report.

Return:

ClassReport

public getCurrentMethodReport(): ClassMethodReport | ModuleMethodReport source

Returns the current method report.

public getErrors(options: object): Array<AnalyzeError | {error: AnalyzeError, source: *}> source

Gets all errors stored in the module report and by default any module methods and class reports.

Params:

NameTypeAttributeDescription
options object

Optional parameters.

Return:

Array<AnalyzeError | {error: AnalyzeError, source: *}>

Return Properties:

NameTypeAttributeDescription
includeChildren boolean

If false then module errors are not included; default (true).

includeReports boolean

If true then results will be an array of object hashes containing source (the source report object of the error) and error (an AnalyzeError instance) keys; default (false).

public getName(): string source

Returns the name / id associated with this report.

Return:

string

public getSetting(key: string, defaultValue: *): * source

Returns the setting indexed by the given key.

Params:

NameTypeAttributeDescription
key string

A key used to store the setting parameter.

defaultValue *

A default value to return if no setting for the given key is currently stored.

Return:

*

public halsteadItemEncountered(metric: string, identifier: string) source

Increments the Halstead metric for the given identifier for the ModuleReport and any current class or method report being tracked.

Params:

NameTypeAttributeDescription
metric string

A Halstead metric name.

identifier string

A Halstead identifier name.

public incrementCyclomatic(amount: number) source

Increments the cyclomatic metric for the ModuleReport and any current class or method report being tracked.

Params:

NameTypeAttributeDescription
amount number

Amount to increment.

public incrementLogicalSloc(amount: number) source

Increments the logical SLOC (source lines of code) metric for the ModuleReport and any current class or method report being tracked.

Params:

NameTypeAttributeDescription
amount number

Amount to increment.

public popScope(type: string): * source

Pops a report scope.

Params:

NameTypeAttributeDescription
type string

The report scope class or method to pop off the given stack.

Return:

*

public processHalsteadItems(metric: string, identifiers: Array<string>) source

Processes all TraitHalstead identifier data.

Params:

NameTypeAttributeDescription
metric string

The Halstead metric being processed.

identifiers Array<string>

An array of Halstead identifiers.

public setSetting(key: string, value: *): boolean source

Sets the setting indexed by the given key and returns true if successful.

Params:

NameTypeAttributeDescription
key string

A key used to store the setting parameter.

value *

A value to set to this.settings[key].

Return:

boolean