Home Manual Reference Source Test Repository
public class | source

PluginMetricsProject

Provides default project metrics gathering and calculation.

See:

Member Summary

Public Members
public

Stores the settings for all ESComplexProject plugins.

Method Summary

Public Methods
public

Loads any default settings that are not already provided by any user options.

public

Performs final calculations based on collected project report data.

public

Stores settings.

Private Methods
private

_calculateAdjacencyMatrix(pathModule: object, projectReport: object): Array<Array<number>>

Calculates an adjacency matrix for all modules based on ES Module and CommonJS dependencies also storing a compacted while returning the matrix for further calculation.

private

_calculateAverages(projectReport: object)

Calculates average ModuleReport metrics that are applicable to ProjectResult.

private

_calculateCoreSize(projectReport: object, visibilityMatrix: Array<Array<number>>): *

Calculates core size which is the percentage of modules / files that are both widely depended on and themselves depend on other modules.

private

_calculateVisibilityMatrix(projectReport: object, adjacencyMatrix: Array<Array<number>>): Array<Array<number>>

Stores a compacted form of the visibility matrix.

private

_doesDependencyExist(pathModule: object, fromModuleReport: ModuleReport, toModuleReport: ModuleReport): boolean

Determines if there is at least one dependency that matches toModuleReport.srcPath from all the dependencies stored in fromModuleReport.

Public Members

public settings: object source

Stores the settings for all ESComplexProject plugins.

Public Methods

public onConfigure(ev: object) source

Loads any default settings that are not already provided by any user options.

Params:

NameTypeAttributeDescription
ev object

escomplex plugin event data.

The following options are:

(boolean)   newmi - Boolean indicating whether the maintainability index should be rebased on a scale from
                    0 to 100; defaults to false.

public onProjectEnd(ev: object) source

Performs final calculations based on collected project report data.

Params:

NameTypeAttributeDescription
ev object

escomplex plugin event data.

public onProjectStart(ev: object) source

Stores settings.

Params:

NameTypeAttributeDescription
ev object

escomplex plugin event data.

Private Methods

private _calculateAdjacencyMatrix(pathModule: object, projectReport: object): Array<Array<number>> source

Calculates an adjacency matrix for all modules based on ES Module and CommonJS dependencies also storing a compacted while returning the matrix for further calculation. Each row index corresponds to the same module index. Each row entry corresponds to a module index. These relationships dictate the dependencies between all module ModuleReports given the source paths.

Params:

NameTypeAttributeDescription
pathModule object

A module that conforms to the Node path API.

projectReport object

The ProjectResult being processed.

Return:

Array<Array<number>>

private _calculateAverages(projectReport: object) source

Calculates average ModuleReport metrics that are applicable to ProjectResult.

Params:

NameTypeAttributeDescription
projectReport object

The ProjectResult being processed.

private _calculateCoreSize(projectReport: object, visibilityMatrix: Array<Array<number>>): * source

Calculates core size which is the percentage of modules / files that are both widely depended on and themselves depend on other modules. Lower is better.

Params:

NameTypeAttributeDescription
projectReport object

The ProjectResult being processed.

visibilityMatrix Array<Array<number>>

The calculated visibilityMatrix.

Return:

*

private _calculateVisibilityMatrix(projectReport: object, adjacencyMatrix: Array<Array<number>>): Array<Array<number>> source

Stores a compacted form of the visibility matrix. Each row index corresponds to the same module index. Each row entry corresponds to a module index. These relationships dictate the reverse visibility between all module ModuleReports which may indirectly impact the given module / file. The full matrix is returned for further calculation.

Implementation of Floyd Warshall algorithm for calculating visibility matrix in O(n^3) instead of O(n^4) with successive raising of powers.

Params:

NameTypeAttributeDescription
projectReport object

The ProjectResult being processed.

adjacencyMatrix Array<Array<number>>

The calculated adjacencyMatrix.

Return:

Array<Array<number>>

private _doesDependencyExist(pathModule: object, fromModuleReport: ModuleReport, toModuleReport: ModuleReport): boolean source

Determines if there is at least one dependency that matches toModuleReport.srcPath from all the dependencies stored in fromModuleReport.

Params:

NameTypeAttributeDescription
pathModule object

A module that conforms to the Node path API.

fromModuleReport ModuleReport

A ModuleReport to match to the srcPath of toModuleReport.

toModuleReport ModuleReport

A ModuleReport providing the srcPath to match.

Return:

boolean