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) {
- Read upRead up
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) {
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
}
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
File config.js
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
System.config({
baseURL: "/public",
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
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')
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)
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)
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)
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) {
- Read upRead up
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
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()
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) {
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)
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
})
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
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)
- Read upRead up
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) {
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.)
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)