Zelgadis87/ML.js

View on GitHub

Showing 11 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

          Trailing spaces not allowed.
          Open

                      if ( "default" in lib ) { 
          Severity: Minor
          Found in src/ModuleLoader.js by eslint

          disallow trailing whitespace at the end of lines (no-trailing-spaces)

          Sometimes in the course of editing files, you can end up with extra whitespace at the end of lines. These whitespace differences can be picked up by source control systems and flagged as diffs, causing frustration for developers. While this extra whitespace causes no functional issues, many code conventions require that trailing spaces be removed before check-in.

          Rule Details

          This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines.

          Examples of incorrect code for this rule:

          /*eslint no-trailing-spaces: "error"*/
          
          var foo = 0;//•••••
          var baz = 5;//••
          //•••••

          Examples of correct code for this rule:

          /*eslint no-trailing-spaces: "error"*/
          
          var foo = 0;
          var baz = 5;

          Options

          This rule has an object option:

          • "skipBlankLines": false (default) disallows trailing whitespace on empty lines
          • "skipBlankLines": true allows trailing whitespace on empty lines

          skipBlankLines

          Examples of correct code for this rule with the { "skipBlankLines": true } option:

          /*eslint no-trailing-spaces: ["error", { "skipBlankLines": true }]*/
          
          var foo = 0;
          var baz = 5;
          //•••••

          Source: http://eslint.org/docs/rules/

          Severity
          Category
          Status
          Source
          Language