lsm/micromono

View on GitHub

Showing 91 of 91 total issues

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

module.exports = function(app) {
  var layoutName = app.get('micromono layout name') || 'layout'
  app.set('micromono layout name', layoutName)

  return function renderLayout(req, res, next) {
Severity: Minor
Found in lib/web/middleware/layout.js - About 6 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 exports has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(app) {
  var layoutName = app.get('micromono layout name') || 'layout'
  app.set('micromono layout name', layoutName)

  return function renderLayout(req, res, next) {
Severity: Major
Found in lib/web/middleware/layout.js - About 3 hrs to fix

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

        fs.stat(outFileCss, function(err, stats) {
          if (stats && stats.isFile()) {
            logger.debug('JSPM css file bundled', {
              outFile: outFileCss
            })
    Severity: Major
    Found in lib/web/asset/bundle.js and 1 other location - About 3 hrs to fix
    lib/web/asset/bundle.js on lines 73..83

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

    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

        fs.stat(outFileJs, function(err, stats) {
          if (stats && stats.isFile()) {
            logger.debug('JSPM js file bundled', {
              outFile: outFileJs
            })
    Severity: Major
    Found in lib/web/asset/bundle.js and 1 other location - About 3 hrs to fix
    lib/web/asset/bundle.js on lines 89..99

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

    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

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

        if (session && 'string' === typeof session) {
          session = JSON.parse(session)
          // Dencrypt session
          next(null, 'session', session)
        } else if (cookie) {
    Severity: Major
    Found in example/channel/channel-a.js and 1 other location - About 3 hrs to fix
    example/channel/channel-b.js on lines 7..22

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

    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

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

        if (session && 'string' === typeof session) {
          session = JSON.parse(session)
          // Dencrypt session
          next(null, 'session', session)
        } else if (cookie) {
    Severity: Major
    Found in example/channel/channel-b.js and 1 other location - About 3 hrs to fix
    example/channel/channel-a.js on lines 9..24

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

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

      return function renderLayout(req, res, next) {
        if (req.__micromono_layout_attached__) {
          next()
          return
        }
    Severity: Major
    Found in lib/web/middleware/layout.js - About 3 hrs to fix

      Function rebuildRemoteMiddlewares has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.rebuildRemoteMiddlewares = function(middlewares, service) {
        Object.keys(middlewares).forEach(function(mName) {
          var middleware = middlewares[mName]
          var _path = middleware.path
      
      
      Severity: Major
      Found in lib/web/router.js - About 2 hrs to fix

        File config.js has 276 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        System.config({
          baseURL: "/public",
          defaultJSExtensions: true,
          transpiler: "babel",
          babelOptions: {
        Severity: Minor
        Found in example/balancer/public/config.js - About 2 hrs to fix

          File backend.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          var Url = require('url')
          var type = require('socketmq/lib/message/type')
          var logger = require('../logger')('micromono:channel:backend')
          var toArray = require('lodash.toarray')
          var socketmq = require('socketmq')
          Severity: Minor
          Found in lib/channel/backend.js - About 2 hrs to fix

            Function handler has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var handler = function() {
                  return function(req, res, next) {
                    var provider = service.scheduler.get()
                    if (!provider) {
                      exports.noProviderAvailable(req, res, next)
            Severity: Major
            Found in lib/web/router.js - About 2 hrs to fix

              Function connect has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              AxonAdapter.connect = function(provider) {
                var self = this
                var name = provider.name
                var endpoint = 'tcp://' + provider.host + ':' + provider.rpc.port
                debug('[%s] connecting to endpoint "%s"', name, endpoint)
              Severity: Major
              Found in example/rpc-adapters/axon.js - About 2 hrs to fix

                Function remoteRequire has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.remoteRequire = function(micromono, serviceName, serviceDir) {
                  var proberPath
                  var ServiceClass
                  var proberCommand
                  var discoveryOptions = exports.getDiscoveryOptions(micromono)
                Severity: Major
                Found in lib/discovery/index.js - About 2 hrs to fix

                  Function attachChannelHooks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                  exports.attachChannelHooks = function(chnAdapter, channel, chnJoinHook, chnAllowHook) {
                    logger.debug('attachChannelHooks').trace(channel)
                  
                    var allowHook = function(pack, stream, dispatch) {
                      if (REQ === pack.type) {
                  Severity: Minor
                  Found in lib/channel/backend.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 end has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      res.end = function(data, encoding, callback) {
                        if (data) {
                          if ('function' === typeof data)
                            callback = data
                          else
                  Severity: Major
                  Found in lib/web/middleware/layout.js - About 2 hrs to fix

                    Function _attachLocalMiddleware has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    ExpressAdapter.prototype._attachLocalMiddleware = function(middleware, service) {
                      var app = this.mapp
                    
                      middleware.handler = middleware.handler.bind(service)
                      var handlerFn = middleware.handler()
                    Severity: Major
                    Found in lib/web/framework/express.js - About 2 hrs to fix

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

                        route: {
                          '/channel': function(req, res) {
                            res.render('index')
                          },
                          '/channel/exit': function(req, res) {
                      Severity: Major
                      Found in example/channel/index.js and 1 other location - About 2 hrs to fix
                      example/io/index.js on lines 13..23

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

                      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

                        route: {
                          '/io': function(req, res) {
                            res.render('index')
                          },
                          '/io/exit': function(req, res) {
                      Severity: Major
                      Found in example/io/index.js and 1 other location - About 2 hrs to fix
                      example/channel/index.js on lines 21..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 76.

                      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

                      firstChannel.req('hello:reply', 'Hi server', function(err, msg) {
                        msg = '<b>/channel/a: </b>' + new Date() + ' reply from server: <br />' + msg
                        var el = document.getElementById('message')
                        el.innerHTML += msg + '<br /><br />'
                      })
                      Severity: Major
                      Found in example/channel/public/main.js and 1 other location - About 1 hr to fix
                      example/channel/public/main.js on lines 44..48

                      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

                      secondChannel.req('hello:reply', 'Hi server', function(err, msg) {
                        msg = '<b>/channel/b: </b>' + new Date() + ' reply from server: <br />' + msg
                        var el = document.getElementById('message')
                        el.innerHTML += msg + '<br /><br />'
                      })
                      Severity: Major
                      Found in example/channel/public/main.js and 1 other location - About 1 hr to fix
                      example/channel/public/main.js on lines 20..24

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language