Zelgadis87/ML.js

View on GitHub

Showing 10 of 12 total issues

ModuleLoader has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class ModuleLoader {

    constructor() {
        this.length = 0;
        this.modules = {};
Severity: Minor
Found in src/ModuleLoader.js - About 3 hrs to fix

    Function registerDirectory has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        registerDirectory( directory, recursive = false ) {
            const entries = fs.readdirSync( directory );
            for ( let entry of entries ) {
                const filepath = path.join( directory, entry );
                const stats = fs.statSync( filepath );
    Severity: Minor
    Found in src/ModuleLoader.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _validateModuleDefinition has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        _validateModuleDefinition( mod ) {
    
            mod.anonymous = false;
    
            if ( isNullOrUndefined( mod.name ) ) {
    Severity: Minor
    Found in src/ModuleLoader.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _validateModuleDefinition has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _validateModuleDefinition( mod ) {
    
            mod.anonymous = false;
    
            if ( isNullOrUndefined( mod.name ) ) {
    Severity: Minor
    Found in src/ModuleLoader.js - About 1 hr to fix

      Function _register1 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          _register1( a ) {
              if ( lodash.isArray( a ) ) {
                  // Array syntax definition
                  let [ deps, prelast, last ] = [ a.slice( 0, -2 ), a.slice( -2, a.length - 1 )[ 0 ], a.slice( -1, a.length )[ 0 ] ];
                  if ( this._isArgValidStart( prelast ) && this._isArgValidStop( last ) ) {
      Severity: Minor
      Found in src/ModuleLoader.js - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function _doStart has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _doStart() {
      
              if ( this.length === 0 )
                  return Bluebird.resolve();
      
      Severity: Minor
      Found in src/ModuleLoader.js - About 1 hr to fix

        Function registerFile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            registerFile( filepath ) {
                let lib = require( filepath );
                let name = this._generateNameFromFilepath( filepath );
        
                /* istanbul ignore if */
        Severity: Minor
        Found in src/ModuleLoader.js - About 1 hr to fix

          Function resolve has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              resolve( dep ) {
          
                  if ( lodash.isArray( dep ) ) {
                      let invalidDependencies = dep.filter( ( name ) => !isValidDependencyName( name ) );
                      if ( invalidDependencies.length > 0 )
          Severity: Minor
          Found in src/ModuleLoader.js - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function registerFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              registerFile( filepath ) {
                  let lib = require( filepath );
                  let name = this._generateNameFromFilepath( filepath );
          
                  /* istanbul ignore if */
          Severity: Minor
          Found in src/ModuleLoader.js - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function _doStart has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              _doStart() {
          
                  if ( this.length === 0 )
                      return Bluebird.resolve();
          
          Severity: Minor
          Found in src/ModuleLoader.js - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Severity
          Category
          Status
          Source
          Language