BohemiaInteractive/bi-service

View on GitHub
lib/common/route.js

Summary

Maintainability
C
1 day
Test Coverage

File route.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const _            = require('lodash');
const Promise      = require('bluebird');
const EventEmitter = require('events-bluebird');
Severity: Minor
Found in lib/common/route.js - About 3 hrs to fix

    Function build has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Route.prototype.build = function() {
    
        const self = this;
        this.emit('build');
    
    
    Severity: Minor
    Found in lib/common/route.js - About 1 hr to fix

      Function acceptsContentType has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Route.prototype.acceptsContentType = function(type, options, parser) {
      
          type = typeis.normalize(type);
      
          if (this.$dataParserMiddleware === null) {
      Severity: Minor
      Found in lib/common/route.js - About 1 hr to fix

        Function callback has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            return function callback(req, res, next) {
        
                //per request unique context object
                var reqContext = Object.create(Object.prototype, {
                    route: {
        Severity: Minor
        Found in lib/common/route.js - About 1 hr to fix

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

          function Route(options) {
              var defaults = {
                  name: null,
                  url: null,
                  summary: "",
          Severity: Minor
          Found in lib/common/route.js - About 1 hr to fix

            Function applyCatchList has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function applyCatchList(promise, req, res, catchList, index) {
            Severity: Minor
            Found in lib/common/route.js - About 35 mins to fix

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

              Route.prototype.respondsWith = function(descriptor) {
                  var responses = this.description.responses;
                  var code = 200;
              
                  if (descriptor instanceof Function
              Severity: Minor
              Found in lib/common/route.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

              There are no issues that match your filters.

              Category
              Status