lucid-services/serviser

View on GitHub

Showing 56 of 56 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                postgres: {
                    type: 'object',
                    required: ['host'],
                    properties: {
                        host: {type: 'string'},
Severity: Major
Found in lib/configSchema.js and 1 other location - About 4 hrs to fix
lib/configSchema.js on lines 119..139

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 127.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                mysql: {
                    type: 'object',
                    required: ['host'],
                    properties: {
                        host: {type: 'string'},
Severity: Major
Found in lib/configSchema.js and 1 other location - About 4 hrs to fix
lib/configSchema.js on lines 98..118

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 127.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _initializeYargs(ya) {
        ya = ya
        .usage('$0 <command> [options]')
        .command(['run [options..]', 'start', 'serve'], 'Starts serviser app - expects it to be located under cwd', {
            cluster: {
    Severity: Minor
    Found in bin/serviser.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      ResourceManager.prototype.get = function(key) {
          if (!this.resources.hasOwnProperty(key)) {
              throw new Error(`Resource: ${key} not found`);
          }
      
      
      Severity: Major
      Found in lib/resourceManager.js and 1 other location - About 1 hr to fix
      lib/common/app.js on lines 274..280

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 73.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      App.prototype.getRoute = function(uid) {
          if (!this.routes.hasOwnProperty(uid)) {
              throw new Error(`Route ${uid} not found`);
          }
      
      
      Severity: Major
      Found in lib/common/app.js and 1 other location - About 1 hr to fix
      lib/resourceManager.js on lines 25..31

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 73.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      function RouteError(message) {
      
          Error.call(this); //super constructor
          Error.captureStackTrace(this, this.constructor);
      
      Severity: Major
      Found in lib/error/routeError.js and 1 other location - About 1 hr to fix
      lib/error/routerError.js on lines 9..16

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      function RouterError(message) {
      
          Error.call(this); //super constructor
          Error.captureStackTrace(this, this.constructor);
      
      Severity: Major
      Found in lib/error/routerError.js and 1 other location - About 1 hr to fix
      lib/error/routeError.js on lines 10..17

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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 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 listen has 41 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 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 buildRemoteService has 40 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 defaultCmd has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function defaultCmd(argv) {
                
                    //we look for user defined shell commands:
                    config.initialize({fileConfigPath: argv.config});
                    let ya = require('yargs/yargs')();
                Severity: Minor
                Found in bin/serviser.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 _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
                      Severity
                      Category
                      Status
                      Source
                      Language