trailsjs/trailpack-express

View on GitHub
lib/server.js

Summary

Maintainability
D
1 day
Test Coverage

Function registerRoutes has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  registerRoutes(app, server) {
    // Sort the routes so that they are always in the correct express order.
    const routes = app.routes.sort(utils.createSpecificityComparator({ order: 'asc' }))
    const express = app.config.get('web.express')
    const expressRouter = express.Router
Severity: Major
Found in lib/server.js - About 3 hrs to fix

    Function registerMiddlewares has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      registerMiddlewares(app, server) {
        server.use(expressBoom())
        if (this.cors) {
          server.use(cors(this.cors === true ? {} : this.cors))
        }
    Severity: Minor
    Found in lib/server.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 registerViews has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      registerViews(app, server) {
        const viewEngine = app.config.get('views.engine') || null
        const viewEngines = app.config.get('web.views')
    
        if (!viewEngine && !viewEngines) {
    Severity: Minor
    Found in lib/server.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 createServer has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      createServer(app) {
        const main = app.config.get('main')
        const sess = app.config.get('session')
        const express = app.config.get('web.express')
    
    
    Severity: Major
    Found in lib/server.js - About 2 hrs to fix

      File server.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* eslint no-console: [0] */
      'use strict'
      
      const _ = require('lodash')
      const path = require('path')
      Severity: Minor
      Found in lib/server.js - About 2 hrs to fix

        Function registerMiddlewares has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          registerMiddlewares(app, server) {
            server.use(expressBoom())
            if (this.cors) {
              server.use(cors(this.cors === true ? {} : this.cors))
            }
        Severity: Minor
        Found in lib/server.js - About 1 hr to fix

          Function createServer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            createServer(app) {
              const main = app.config.get('main')
              const sess = app.config.get('session')
              const express = app.config.get('web.express')
          
          
          Severity: Minor
          Found in lib/server.js - About 45 mins 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

          There are no issues that match your filters.

          Category
          Status