<internal>
Index
Classes
ESComplex
constructor
Initializes ESComplex.
Parameters
options: { module: { loadDefaultPlugins: boolean; plugins: any[] }; project: { loadDefaultPlugins: boolean; plugins: any[] } } = ...
module and project options including user plugins to load including:
(object) module - Provides an object hash of the following options for the module runtime:
(boolean) loadDefaultPlugins - When false ESComplexModule will not load any default plugins.
(Array<Object>) plugins - A list of ESComplexModule plugins that have already been instantiated.
(object) project - Provides an object hash of the following options for the project runtime:
(boolean) loadDefaultPlugins - When false ESComplexProject will not load any default plugins.
(Array<Object>) plugins - A list of ESComplexProject plugins that have already been instantiated.
Returns ESComplex
analyzeModule
Parses the given source code then processes the generated AST and calculates metrics via plugins.
Parameters
source: string
Javascript source code.
options: ComplexityReporterOptions = DefaultComplexityReporterOptions
Module analyze options.
parserOptions: any = ...
Overrides default Babel parser options.
parserOverride: any = ...
Provides helper directives to override options to simplify modification of default Babel parser options.
Returns default
- A single module report.
analyzeModuleAST
Processes the given ast and calculates metrics via plugins.
Parameters
ast: any
Javascript AST.
options: ComplexityReporterOptions
Module analyze options.
Returns default
- A single module report.
analyzeModuleASTAsync
Wraps in a Promise processing the given ast and calculates metrics via plugins.
Parameters
ast: any
Javascript AST.
options: ComplexityReporterOptions
Module analyze options.
Returns Promise<unknown>
- A single module report.
analyzeModuleAsync
Wraps in a Promise parsing of the given source code then processes the generated AST and calculates metrics via plugins.
Parameters
source: string
Javascript source code.
options: ComplexityReporterOptions
Module analyze options.
parserOptions: any = ...
Overrides default babylon parser options.
parserOverride: any = ...
Provides helper directives to override options to simplify modification of default Babel parser options.
Returns Promise<unknown>
- A single module report.
analyzeProject
Processes the given sources and calculates project metrics via plugins.
Parameters
sources: any[]
Array of object hashes containing
code
andsrcPath
entries with optional entries includefilePath
andsrcPathAlias
.options: any = {}
Project processing options.
parserOptions: any = ...
Overrides default Babel parser options.
parserOverride: any = ...
Provides helper directives to override options to simplify modification of default Babel parser options.
Returns any
- An object hash with a
reports
entry that is an Array of module results.
analyzeProjectAST
Processes the given modules and calculates project metrics via plugins.
Parameters
modules: any[]
Array of object hashes containing
ast
andsrcPath
entries with optional entries includefilePath
andsrcPathAlias
.options: any
(Optional) project processing options.
Returns any
- An object hash with a
reports
entry that is an Array of module results.
analyzeProjectASTAsync
Wraps in a Promise processing the given modules and calculates project metrics via plugins.
Parameters
modules: any[]
Array of object hashes containing
ast
andpath
entries.options: ProjectOptions
Project processing options.
Returns Promise<unknown>
- An object hash with a
reports
entry that is an Array of module results.
analyzeProjectAsync
Wraps in a Promise processing the given sources and calculates project metrics via plugins.
Parameters
sources: any[]
Array of object hashes containing
code
andpath
entries.options: {} = {}
Project processing options.
parserOptions: any = ...
Overrides default babylon parser options.
parserOverride: any = ...
Provides helper directives to override options to simplify modification of default Babel parser options.
Returns Promise<unknown>
- An object hash with a
reports
entry that is an Array of module results.
parse
Provides a convenience method to parse the given source code and return the Babel parser AST.
Parameters
source: string
Javascript source code.
parserOptions: any = ...
Overrides default babylon parser options.
parserOverride: any = ...
Provides helper directives to override options to simplify modification of default Babel parser options.
Returns ParseResult<File>
- babylon generated AST.
parseAsync
Wraps in a Promise a convenience method to parse the given source code and return the babylon AST.
Parameters
source: string
Javascript source code.
parserOptions: any = ...
Overrides default babylon parser options.
parserOverride: any = ...
Provides helper directives to override options to simplify modification of default Babel parser options.
Returns Promise<unknown>
- babylon generated AST.
processProject
Processes existing project results and calculates metrics via plugins.
Parameters
results: any
An object hash with a
reports
entry that is an Array of module results.options: {} = {}
(Optional) project processing options.
Returns any
- An object hash with a
reports
entry that is an Array of module results.
processProjectAsync
Wraps in a Promise processing existing project results and calculates metrics via plugins.
Parameters
results: any
An object hash with a
reports
entry that is an Array of module results.options: {} = {}
(Optional) project processing options.
Returns Promise<unknown>
- An object hash with a
reports
entry that is an Array of module results.
default
Provides a runtime to invoke ESComplexProject plugins for processing / metrics calculations of projects.
constructor
Initializes ESComplexProject.
Parameters
pathModule: PlatformPath
Provides an object which matches the Node path module. In particular the following entries must be provided:
(string) sep - Provides the platform-specific path segment separator: `/` on POSIX & `\` on Windows.
(function) dirname - Returns the directory name of a path, similar to the Unix dirname command.
(function) extname - Returns the extension of the path, from the last occurance of the . (period) character to
end of string in the last portion of the path.
(function) relative - Returns the relative path from from to to.
(function) resolve - Resolves a sequence of paths or path segments into an absolute path.optionaloptions: ProjectOptions
module and project options including user plugins to load including:
(object) module - Provides an object hash of the following options for the module runtime:
(boolean) loadDefaultPlugins - When false ESComplexModule will not load any default plugins.
(Array<Object>) plugins - A list of ESComplexModule plugins that have already been instantiated.
(object) project - Provides an object hash of the following options for the project runtime:
(boolean) loadDefaultPlugins - When false ESComplexProject will not load any default plugins.
(Array<Object>) plugins - A list of ESComplexProject plugins that have already been instantiated.
Returns default
analyze
Processes the given modules and calculates project metrics via plugins.
Parameters
modules: any[]
Array of object hashes containing
ast
andsrcPath
entries. OptionallysrcPathAlias
andfilePath
entries may also be provided.optionaloptions: ComplexityReporterOptions
(Optional) project processing options.
Returns any
analyzeAsync
Wraps in a Promise processing the given modules and calculates metrics via plugins.
Parameters
modules: any[]
Array of object hashes containing
ast
andsrcPath
entries. OptionallysrcPathAlias
andfilePath
entries may also be provided.optionaloptions: {}
project processing options
Returns Promise<unknown>
process
Processes an existing ProjectReport instance and calculates metrics via plugins.
Parameters
projectReport: default
An instance of ProjectReport with a
modules
entry that is an Array of ModuleReports.optionaloptions: {}
(Optional) project processing options.
Returns any
processAsync
Wraps in a Promise processing of existing ProjectReport instance and calculates metrics via plugins.
Parameters
projectReport: default
An instance of ProjectReport.
optionaloptions: {}
(Optional) project processing options.
Returns Promise<unknown>
Interfaces
ComplexityReporterOptions
optionalecmaFeatures
ecmaVersion
loc
newmi
optionalparserOptions
range
sourceType
EcmaFeatures
optionalarrowFunctions
optionalbinaryLiterals
optionalblockBindings
optionalclasses
optionaldefaultParams
optionaldestructuring
optionalexperimentalObjectRestSpread
optionalforOf
optionalgenerators
optionalglobalReturn
optionaljsx
optionalmodules
optionalobjectLiteralComputedProperties
optionalobjectLiteralDuplicateProperties
optionalobjectLiteralShorthandMethods
optionalobjectLiteralShorthandProperties
optionaloctalLiterals
optionalregexUFlag
optionalregexYFlag
optionalrestParams
optionalspread
optionaltemplateStrings
optionaltypescript
optionalunicodeCodePointEscapes
ParserOptions
optionalbabelOptions
ecmaFeatures
sourceType
Plugin
onConfigure
Parameters
options: ComplexityReporterOptions[]
Returns any
onProjectAverage
Parameters
projectReport: any
pathModule: PlatformPath
settings: any
Returns any
onProjectCalculate
Parameters
projectReport: any
pathModule: PlatformPath
settings: any
Returns any
onProjectEnd
Parameters
projectReport: any
pathModule: PlatformPath
settings: any
Returns any
onProjectPostAverage
Parameters
projectReport: any
pathModule: PlatformPath
settings: any
Returns any
onProjectStart
Parameters
projectReport: any
pathModule: PlatformPath
settings: any
Returns any
Next generation code complexity reporting for Javascript abstract syntax trees (AST). ESComplex exposes all methods available via ESComplexModule & ESComplexProject modules which process AST. Several methods available below accept source code which is translated via Babel Parser w/ all plugins enabled allowing any ES6/ES7/edge JS and Typescript to be parsed. Asynchronous versions with the
Async
suffix of all methods are available as well.