BohemiaInteractive/bi-service

View on GitHub

Showing 45 of 53 total issues

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

    Function getConfigCmd has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function getConfigCmd(argv) {
        if (!config.isInitialized()) {
            config.initialize({fileConfigPath: argv.config});
        }
    
    
    Severity: Minor
    Found in lib/cli/getConfigCmd.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 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 toSwagger has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      RequestError.prototype.toSwagger = function() {
          var schema = {
              description: this.desc,
              schema: {
                  type: "object",
      Severity: Minor
      Found in lib/error/requestError.js - About 1 hr to fix

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

        function _runCluster(numOfWorkers) {
        
            if (typeof numOfWorkers !== 'number') {
                numOfWorkers = CPU_COUNT;
            } else if (numOfWorkers <= 0
        Severity: Minor
        Found in lib/cli/runCmd.js - About 1 hr to fix

          Function tick has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  function tick() {
                      let setup = false; //whether the service is "setup" and ready
                      self.once('listening', onServiceListening);
                      self.once('error', onServiceError);
          
          
          Severity: Minor
          Found in lib/service.js - About 1 hr to fix

            Function App has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function App(appManager, config, options) {
                EventEmmiter.call(this);
                const app = this;
            
                /**
            Severity: Minor
            Found in lib/common/app.js - About 1 hr to fix

              Function errorHandler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function errorHandler(err, req, res, next) {
                  //important! this function has to have exactly four arguments defined
                  //as its also used dirrectly by expressjs error handler in express/app.js
                  const app = this;
              
              
              Severity: Minor
              Found in lib/middleware/errorHandler.js - About 1 hr to fix

                Function $setProjectRoot has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                Service.prototype.$setProjectRoot = function(dir) {
                    var p = dir || process.cwd();
                
                    while ((fs.statSync(p)).isDirectory()) {
                        try {
                Severity: Minor
                Found in lib/service.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 resolve has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function resolve(val, key, object) {
                        if (_.isPlainObject(val)) {
                            if (   val.hasOwnProperty('$ref')
                                && typeof val.$ref === 'string'
                            ) {
                Severity: Minor
                Found in lib/utils.js - About 1 hr to fix

                  Function inspectIntegrity has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ResourceManager.prototype.inspectIntegrity = Promise.method(function(tag, options) {
                      options = options || {mode: 'include'};
                      let heap;
                      let resources = _getResources.call(this, tag, options);
                  
                  
                  Severity: Minor
                  Found in lib/resourceManager.js - About 1 hr to fix

                    Function listen has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    App.prototype.listen = function() {
                        var args = Array.prototype.slice.call(arguments, 0, 3);
                        var app = this;
                        var options = {
                            ssl: false,
                    Severity: Minor
                    Found in lib/express/app.js - About 1 hr to fix

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

                      function _runCluster(numOfWorkers) {
                      
                          if (typeof numOfWorkers !== 'number') {
                              numOfWorkers = CPU_COUNT;
                          } else if (numOfWorkers <= 0
                      Severity: Minor
                      Found in lib/cli/runCmd.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 _parseShellConfigOptions has a Cognitive Complexity of 9 (exceeds 5 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 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 errorHandler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function errorHandler(err, req, res, next) {
                          //important! this function has to have exactly four arguments defined
                          //as its also used dirrectly by expressjs error handler in express/app.js
                          const app = this;
                      
                      
                      Severity: Minor
                      Found in lib/middleware/errorHandler.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 _stderr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function _stderr(err) {
                      
                          if (typeof err === 'object' && err !== null) {
                              if (err.toLogger instanceof Function) {
                                  err = err.toLogger();
                      Severity: Minor
                      Found in lib/utils.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 validate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              validate: function(schema, data, parentSchema, dataPath, parentData, prop) {
                      Severity: Minor
                      Found in lib/utils.js - About 45 mins 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 buildRemoteService has a Cognitive Complexity of 7 (exceeds 5 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 35 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

                          Avoid too many return statements within this function.
                          Open

                                  return errorHandler.errorHandler.call(app, ServiceError.buildFrom(err), req, res);
                          Severity: Major
                          Found in lib/middleware/errorHandler.js - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language