dominiklessel/node-restify-boilerplate

View on GitHub

Showing 8 of 10 total issues

Function exports has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function() {

  var parseAuthorization = function(req, res, next) {

    var credentialList = nconf.get('Security:Users');
Severity: Major
Found in plugins/customAuthorizationParser.js - About 2 hrs to fix

    Function parseAuthorization has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var parseAuthorization = function(req, res, next) {
    
        var credentialList = nconf.get('Security:Users');
        var allowAnon = nconf.get('Security:AllowAnonymous');
        var authorizationHeader;
    Severity: Minor
    Found in plugins/customAuthorizationParser.js - About 1 hr to fix

      Function exports has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function() {
      
        var parseAuthorization = function(req, res, next) {
      
          var credentialList = nconf.get('Security:Users');
      Severity: Minor
      Found in plugins/customAuthorizationParser.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

      Avoid too many return statements within this function.
      Open

            return next(new restify.NotAuthorizedError('Authorization key unknown.'));
      Severity: Major
      Found in plugins/customAuthorizationParser.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return next(new restify.InvalidHeaderError('Authorization scheme is invalid.'));
        Severity: Major
        Found in plugins/customAuthorizationParser.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return next(new restify.NotAuthorizedError('Authorization signature is invalid.'));
          Severity: Major
          Found in plugins/customAuthorizationParser.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return next();
            Severity: Major
            Found in plugins/customAuthorizationParser.js - About 30 mins to fix

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

              var CORSHelper = function(options) {
              
                var allowedOrigins = options.origins || [];
                var allowedHeaders = restify.CORS.ALLOW_HEADERS.concat(options.headers || []);
              
              
              Severity: Minor
              Found in helpers/corsHelper.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