bq/corbel-composr

View on GitHub

Showing 59 of 59 total issues

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

module.exports = {
  loadRoutes: function (server) {
    server.del('/snippet/:itemId', function (req, res, next) {
      Snippet.delete(req, res, next)
    })
Severity: Major
Found in src/routes/snippet.js and 1 other location - About 1 day to fix
src/routes/phrase.js on lines 20..54

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 287.

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

module.exports = {
  loadRoutes: function (server) {
    server.put('/phrase', function (req, res, next) {
      Phrase.upsert(req, res, next)
    })
Severity: Major
Found in src/routes/phrase.js and 1 other location - About 1 day to fix
src/routes/snippet.js on lines 13..47

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 287.

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

function initMetrics (config, logger) {
  if (yn(config.get('keymetrics'))) {
    logger.info('[Keymetrics]', 'Initializing Keymetrics probes...')

    var probe = pmx.probe()
Severity: Major
Found in src/metrics/keymetrics.js - About 4 hrs to fix

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

    Worker.prototype._addSnippet = function (domain, id) {
      return this.engine.composr.Snippet.load(id)
        .then(function (item) {
          logger.debug('[RabbitMQ Eworker]', 'RabbitMQ-worker snippet fetched', item.id, 'registered', item.registered)
          return item.registered
    Severity: Major
    Found in src/lib/rabbitMQworker.js and 1 other location - About 2 hrs to fix
    src/lib/rabbitMQworker.js on lines 40..46

    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 93.

    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

    Worker.prototype._addPhrase = function (domain, id) {
      return this.engine.composr.Phrase.load(id)
        .then(function (item) {
          logger.debug('[RabbitMQ Eworker]', 'RabbitMQ-worker phrase fetched', item.id, 'registered', item.registered)
          return item.registered
    Severity: Major
    Found in src/lib/rabbitMQworker.js and 1 other location - About 2 hrs to fix
    src/lib/rabbitMQworker.js on lines 52..58

    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 93.

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

    module.exports = function (phraseModel, verb) {
      var methodDoc = phraseModel.getDoc(verb)
    
      return function mockHock (req, res, next) {
        if (methodDoc && methodDoc.responses) {
    Severity: Minor
    Found in src/lib/phraseHooks/mockHook.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 initMetrics has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function initMetrics (config, logger) {
      if (yn(config.get('newrelic.enabled'))) {
        newrelic = require('newrelic')
        logger.info('[Metrics]', 'Initializing NewRelic events...')
        fProxy.proxifyFunction(newrelic, ['agent', '_transactionFinished'], function (cb, transaction) {
    Severity: Major
    Found in src/metrics/newrelic.js - About 2 hrs to fix

      Function init has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        init: function (app, localMode, serverID, maxServicesRetries) {
          return new Promise(function (resolve, reject) {
            // Suscribe to log events
            engine.suscribeToCoreEvents()
            engine.suscribeToCacheEvents()
      Severity: Minor
      Found in src/lib/engine.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 exports has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function (server) {
        server.get('/e1', function (res) {
          res.undefinedFunction()
        })
      
      
      Severity: Minor
      Found in src/routes/test.js - About 1 hr to fix

        Function executePhrase has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function executePhrase (req, res, next, routeItem) {
          var params = executionMode({
            corbelDriver: req.corbelDriver,
            req: req,
            res: res,
        Severity: Minor
        Found in src/lib/router.js - About 1 hr to fix

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

            init: function (app, localMode, serverID, maxServicesRetries) {
              return new Promise(function (resolve, reject) {
                // Suscribe to log events
                engine.suscribeToCoreEvents()
                engine.suscribeToCacheEvents()
          Severity: Minor
          Found in src/lib/engine.js - About 1 hr to fix

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

            Worker.prototype.init = function (cb) {
              var conn
              var that = this
              logger.info('[RabbitMQ Eworker]', 'Creating RabbitMQ-worker with ID', that.workerID)
            
            
            Severity: Minor
            Found in src/lib/rabbitMQworker.js - About 1 hr to fix

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

              function checkServerStatus (req, res) {
                var domain = req.params.domain || null
                var phrases = engine.composr.Phrase.getPhrases(domain)
              
                var version = req.params.version
              Severity: Minor
              Found in src/routes/base.js - About 1 hr to fix

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

                module.exports = function (restify, server, logger) {
                  /* *************************************
                    Sanitize Path
                  **************************************/
                  var sanitize = require('../utils/prePath')
                Severity: Minor
                Found in src/middlewares/http.js - About 1 hr to fix

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

                  function checkState (timeout) {
                    var modules = ['iam', 'resources', 'assets', 'evci']
                    var path = config.get('corbel.options.urlBase')
                  
                    var result = {}
                  Severity: Minor
                  Found in src/lib/connectors/corbel.js - About 1 hr to fix

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

                    module.exports = function (phraseModel, verb) {
                      if (engine.services.redis) {
                        return function cacheHook (req, res, next) {
                          var path = req.getHref()
                    
                    
                    Severity: Minor
                    Found in src/lib/phraseHooks/cacheHook.js - About 1 hr to fix

                      Function delete has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ResourceEndpoint.prototype.delete = function (req, res) {
                        var that = this
                        var authorization = this.getAuthorization(req)
                        var driver = this.getDriver(authorization)
                        var domain = this.getDomain(authorization)
                      Severity: Minor
                      Found in src/routes/BaseResource.endpoint.js - About 1 hr to fix

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

                        function info () {
                          if (logLevel) {
                            logger.log.apply(logger, ['info'].concat(Array.prototype.slice.call(arguments)))
                          }
                        }
                        Severity: Major
                        Found in src/utils/composrLogger.js and 1 other location - About 1 hr to fix
                        src/utils/composrLogger.js on lines 62..66

                        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 57.

                        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 warn () {
                          if (logLevel) {
                            logger.log.apply(logger, ['warn'].concat(Array.prototype.slice.call(arguments)))
                          }
                        }
                        Severity: Major
                        Found in src/utils/composrLogger.js and 1 other location - About 1 hr to fix
                        src/utils/composrLogger.js on lines 56..60

                        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 57.

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

                        module.exports = function (phraseModel, verb) {
                          var methodDoc = phraseModel.getDoc(verb)
                        
                          return function mockHock (req, res, next) {
                            if (methodDoc && methodDoc.responses) {
                        Severity: Minor
                        Found in src/lib/phraseHooks/mockHook.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language