BohemiaInteractive/bi-service

View on GitHub

Showing 45 of 53 total issues

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 resolveSchemaRefs has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function resolveSchemaRefs(val, validator, _root) {
    
        _root = _root || val;
        resolve(val, '', val);
        return val;
    Severity: Minor
    Found in lib/utils.js - About 3 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 filter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    function filter(data, route) {
    
        var res = this
        ,   statusCode = res.statusCode
        ,   validator = route.Router.App.getValidator()
    Severity: Minor
    Found in lib/response.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 _initializeYargs has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _initializeYargs(ya) {
        ya = ya
        .usage('$0 <command> [options]')
        .command(['run [options..]', 'start', 'serve'], 'Starts bi-service app - expects it to be located under cwd', {
            cluster: {
    Severity: Minor
    Found in bin/bi-service.js - About 1 hr to fix

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

      module.exports = function(valDef, dataProp) {
      
          const validator = this.Router.App.getValidator();
          const ErrorConstructor = validator.ValidationErrorConstructor;
          var validate;
      Severity: Minor
      Found in lib/middleware/validator.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 filter has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function filter(data, route) {
      
          var res = this
          ,   statusCode = res.statusCode
          ,   validator = route.Router.App.getValidator()
      Severity: Minor
      Found in lib/response.js - About 1 hr to fix

        Function $init has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        App.prototype.$init = function() {
        
            var self = this;
            this.expressApp.locals.getUrl = function getUrl(uid, pathParams, queryParams) {
                return self.getRoute(uid).getUrl(pathParams, queryParams);
        Severity: Minor
        Found in lib/express/app.js - About 1 hr to fix

          Function defaultCmd has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function defaultCmd(argv) {
          
              if (argv['get-conf'] !== undefined) {
                  getConfigCmd(argv);
              //if no supported commands or options were matched so far,
          Severity: Minor
          Found in bin/bi-service.js - About 1 hr to fix

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

            function getPaginationMeta(opt) {
            
                opt = opt || {};
            
                opt.limit = typeof opt.limit !== 'number' ?
            Severity: Minor
            Found in lib/utils.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 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 _parseShellConfigOptions has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function _parseShellConfigOptions(argv) {
                  var out = {};
              
                  //`parse-pos-args` value is `true` by default, it must be
                  //explicitly set to falsy value thus undefined & null values does not count
              Severity: Minor
              Found in lib/cli/runCmd.js - About 1 hr to fix

                Function fileIterator has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function fileIterator(paths, options, callback) {
                    var filePacks = [];
                    if (typeof options === 'function') {
                        callback = options;
                        options = {};
                Severity: Minor
                Found in lib/moduleLoader.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 listen has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      Service.prototype.listen = function() {
                          const self = this;
                      
                          return new Promise(function(resolve, reject) {
                      
                      
                      Severity: Minor
                      Found in lib/service.js - About 1 hr to fix

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

                        function registerCustomKeywords(ajv) {
                            //register $desc - aka. property description keyword
                            ajv.addKeyword('$desc', {
                                schema: false,
                                valid: true,
                        Severity: Minor
                        Found in lib/utils.js - About 1 hr to fix

                          Function buildRemoteService has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          RemoteServiceManager.prototype.buildRemoteService = function(key, options) {
                              let keySegments = key.split(':');
                              let serviceName = keySegments[0];
                              let scope       = keySegments[1];
                              let sdkPath     = keySegments.slice(2);
                          Severity: Minor
                          Found in lib/remoteServiceManager.js - About 1 hr to fix

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

                            module.exports = function(valDef, dataProp) {
                            
                                const validator = this.Router.App.getValidator();
                                const ErrorConstructor = validator.ValidationErrorConstructor;
                                var validate;
                            Severity: Minor
                            Found in lib/middleware/validator.js - About 1 hr to fix

                              Function testConfigCmd has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function testConfigCmd(argv) {
                                  let userSchema;
                              
                                  try {
                                      if (argv.schema) {
                              Severity: Minor
                              Found in lib/cli/testConfigCmd.js - About 1 hr to fix

                                Function resolveSchemaRefs has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function resolveSchemaRefs(val, validator, _root) {
                                
                                    _root = _root || val;
                                    resolve(val, '', val);
                                    return val;
                                Severity: Minor
                                Found in lib/utils.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language