CleverStack/clever-controller

View on GitHub

Showing 8 of 8 total issues

Function extend has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    extend: function() {
        var extendingArgs = [].slice.call( arguments )
          , autoRouting = ( extendingArgs.length === 2 ) ? extendingArgs[ 0 ].autoRouting !== false : this.autoRouting
          , definedRoute = ( extendingArgs.length === 2 ) ? extendingArgs[ 0 ].route !== undefined : this.route;

Severity: Minor
Found in controller.js - About 2 hrs 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 performanceSafeSetup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    performanceSafeSetup: function( req, res, next ) {
        var methodAction    = req.method.toLowerCase() + 'Action'
          , actionRouting   = this.Class.actionRouting
          , actionMethod    = /\/([a-zA-z\.]+)(\/?|\?.*|\#.*)?$/ig.test( req.url ) ? RegExp.$1 + 'Action' : ( req.params.action !== undefined ? req.params.action : false )
          , restfulRouting  = this.Class.restfulRouting
Severity: Minor
Found in controller.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 extend has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    extend: function() {
        var extendingArgs = [].slice.call( arguments )
          , autoRouting = ( extendingArgs.length === 2 ) ? extendingArgs[ 0 ].autoRouting !== false : this.autoRouting
          , definedRoute = ( extendingArgs.length === 2 ) ? extendingArgs[ 0 ].route !== undefined : this.route;

Severity: Minor
Found in controller.js - About 1 hr to fix

    Function performanceSafeSetup has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        performanceSafeSetup: function( req, res, next ) {
            var methodAction    = req.method.toLowerCase() + 'Action'
              , actionRouting   = this.Class.actionRouting
              , actionMethod    = /\/([a-zA-z\.]+)(\/?|\?.*|\#.*)?$/ig.test( req.url ) ? RegExp.$1 + 'Action' : ( req.params.action !== undefined ? req.params.action : false )
              , restfulRouting  = this.Class.restfulRouting
    Severity: Minor
    Found in controller.js - About 1 hr to fix

      Function init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          init: function( error, method, next ) {
              if ( error && error instanceof NoActionException ) {
                  debug( 'No route mapping found, calling next()' );
                  next();
              } else {
      Severity: Minor
      Found in controller.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 autoRoute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          autoRoute: function( app ) {
              var middleware  = []
                , routes      = this.route instanceof Array ? this.route : this.route.split( '|' );
              
              debug( 'Autorouting for route ' + routes.join( ', ' ) );
      Severity: Minor
      Found in controller.js - About 1 hr to fix

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

            setup: function() {
                if ( this.autoRouting !== false && this.route !== false && routedControllers.indexOf( this.route ) === -1 ) {
        
                    routedControllers.push( this.route );
                    
        Severity: Minor
        Found in controller.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 send has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            send: function( content, code, type ) {
                if ( !this.responseSent && !this.res.complete ) {
                    this.responseSent = true;
                    var toCall = type || this.resFunc;
                    if ( code ) {
        Severity: Minor
        Found in controller.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

        Severity
        Category
        Status
        Source
        Language