import ModuleReport from 'typhonjs-escomplex-commons/src/module/report/ModuleReport.js'ModuleReport
Extends:
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 |
getFormats(): Object[] Returns the supported transform formats. |
|
| public static |
parse(object: object): ModuleReport 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 |
type: ReportType: * Returns the enum for the report type. |
|
| Private Members | ||
| private |
Stores the current class report scope stack which is lazily created in |
|
| private |
_scopeStackMethod: Array<ClassMethodReport | ModuleMethodReport> Stores the current method report scope stack which is lazily created in |
|
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 |
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 |
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 |
|
| public |
incrementCyclomatic(amount: number) Increments the cyclomatic metric for the ModuleReport and any current class or method report being tracked. |
|
| public |
incrementLogicalSloc(amount: number) Increments the logical SLOC (source lines of code) metric for the ModuleReport and any current class or method report being tracked. |
|
| public |
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 |
|
| public |
Stores any associated |
|
| public |
incrementDistinctHalsteadItems(metric: string, identifier: string) 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 |
incrementHalsteadMetric(metric: string, type: string) Increments the associated aggregate report Halstead metric type. |
|
| public |
incrementParams(count: number) Increments the associated aggregate report parameter count. |
|
| public |
isHalsteadMetricDistinct(metric: string, identifier: string): boolean Returns true if a given HalsteadData metric / identifier is not found in the associated aggregate report. |
|
| public |
Formats this report given the type. |
|
Static Public Methods
public static parse(object: object): ModuleReport source
Deserializes a JSON object representing a ModuleReport.
Params:
| Name | Type | Attribute | Description |
| object | object | A JSON object of a ModuleReport that was previously serialized. |
Public Constructors
public constructor(lineStart: number, lineEnd: number, settings: object) source
Initializes the report.
Override:
AbstractReport#constructorPublic Members
public filePath: string source
Stores the file path of the module / file. The file path is only defined as supplied when processing projects.
public maintainability: number source
Measures the average method maintainability index for the module / file.
public methods: Array<ModuleMethodReport> source
Stores all module ModuleMethodReport data found outside of any ES6 classes.
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.
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.
public clearErrors(clearChildren: boolean) source
Clears all errors stored in the module report and by default any class reports and module methods.
Params:
| Name | Type | Attribute | Description |
| 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.
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:
| Name | Type | Attribute | Description |
| options | object | Optional parameters. |
Return:
| Array<AnalyzeError | {error: AnalyzeError, source: *}> |
Return Properties:
| Name | Type | Attribute | Description |
| 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 |
public getSetting(key: string, defaultValue: *): * source
Returns the setting indexed by the given key.
Params:
| Name | Type | Attribute | Description |
| 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.
public incrementCyclomatic(amount: number) source
Increments the cyclomatic metric for the ModuleReport and any current class or method report being tracked.
Params:
| Name | Type | Attribute | Description |
| 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:
| Name | Type | Attribute | Description |
| amount | number | Amount to increment. |
public popScope(type: string): * source
Pops a report scope.
Params:
| Name | Type | Attribute | Description |
| type | string | The report scope |
Return:
| * |