lsm/micromono

View on GitHub

Showing 55 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

    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

                      Function checkRemoteServicesAvailability has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.checkRemoteServicesAvailability = function(services, discoveryOptions) {
                        var minInterval = 3000
                        var remoteServices = []
                      
                        Object.keys(services).forEach(function(serviceName) {
                      Severity: Minor
                      Found in lib/service/remote.js - About 1 hr to fix

                        Function getProxyHandler has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        exports.getProxyHandler = function(scheduler, httpServer, upgradeUrl) {
                          var proxy = httpProxy.createProxyServer({})
                        
                          if (httpServer && upgradeUrl) {
                            var re = new RegExp('^' + upgradeUrl)
                        Severity: Minor
                        Found in lib/web/router.js - About 1 hr to fix

                          Function startBalancer has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          exports.startBalancer = function(micromono, app, callback) {
                            var packagePath = ServerPipe.getCallerPath()
                            logger.info('Start balancer pipeline').debug({
                              packagePath: packagePath
                            })
                          Severity: Minor
                          Found in lib/entrance/balancer.js - About 1 hr to fix

                            Function startService has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            exports.startService = function(micromono, Service, callback, cbDependencies) {
                              logger.info('Start service pipeline')
                              // Get instance of service.
                              var service = 'function' === typeof Service ? new Service() : Service
                              // Prepare global service dependencies
                            Severity: Minor
                            Found in lib/entrance/service.js - About 1 hr to fix

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

                              exports.prepareBundleInfo = function(assetInfo, publicPath, bundleOptions) {
                                // Prepare bundleOptions for jspm/systemjs builder
                                bundleOptions.name = assetInfo.name
                                bundleOptions = getDefaultBundleOptions(bundleOptions)
                              
                              
                              Severity: Minor
                              Found in lib/web/asset/bundle.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 ensureChannelGateway has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              exports.ensureChannelGateway = function(services, set) {
                                logger.debug('ensureChannelGateway')
                              
                                var chnGateway
                                var hasServiceWithChannel = Object.keys(services).some(function(name) {
                              Severity: Minor
                              Found in lib/channel/gateway.js - About 1 hr to fix

                                Function getCommonBundles has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                exports.getCommonBundles = function(assetInfo, servicesWithAsset, assetDependenciesMap) {
                                  var numServices = servicesWithAsset.length
                                  // Any dependency required by 70% or more of the services
                                  // Minus any dependencies in assetInfo.micromono.bundleDeps
                                  // (which will be bundled with the main bundle.)
                                Severity: Minor
                                Found in lib/web/asset/pjson.js - About 1 hr to fix

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

                                  exports.bundle = function(assetInfo, packagePath, jspmBinPath, bundleCmd, bundleOptions, set) {
                                    var publicURL = assetInfo.publicURL[0]
                                    jspm.runJSPM(packagePath, jspmBinPath, bundleCmd.split(' '), function(err) {
                                      if (err)
                                        return set('error', err)
                                  Severity: Minor
                                  Found in lib/web/asset/bundle.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language