trailsjs/trailpack-express

View on GitHub

Showing 25 of 40 total issues

Function createSpecificityComparator has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring.
Open

  createSpecificityComparator: function(options) {
    const self = this
    options = options || {}
    // Ascending order flag, defaults to false
    let asc = false
Severity: Minor
Found in lib/utils.js - About 2 days 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 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 createSpecificityComparator has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      createSpecificityComparator: function(options) {
        const self = this
        options = options || {}
        // Ascending order flag, defaults to false
        let asc = false
    Severity: Major
    Found in lib/utils.js - About 2 hrs to fix

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

              return function specificityComparator(routeA, routeB) {
                routeA = (routeA.path || '').toLowerCase()
                routeB = (routeB.path || '').toLowerCase()
                // If it's the default route, push it all the way
                // over to one of the ends
          Severity: Minor
          Found in lib/utils.js - About 1 hr to fix

            Function createResponse has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              createResponse: function(req, res, next) {
                const response = (data) => {
            
                  return new Promise((resolve, reject) => {
                    if (!data) {
            Severity: Minor
            Found in lib/utils.js - About 1 hr to fix

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

                findAssociation(req, res) {
                  const FootprintService = this.app.services.FootprintService
                  const options = this.app.packs.express.getOptionsFromQuery(req.query)
                  const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
                  const parentModel = req.params.parentModel
              Severity: Minor
              Found in api/controllers/FootprintController.js - About 1 hr to fix

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

                  destroyAssociation(req, res) {
                    const FootprintService = this.app.services.FootprintService
                    const options = this.app.packs.express.getOptionsFromQuery(req.query)
                    const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
                    const parentModel = req.params.parentModel
                Severity: Minor
                Found in api/controllers/FootprintController.js - About 1 hr to fix

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

                    updateAssociation(req, res) {
                      const FootprintService = this.app.services.FootprintService
                      const options = this.app.packs.express.getOptionsFromQuery(req.query)
                      const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
                      const parentModel = req.params.parentModel
                  Severity: Minor
                  Found in api/controllers/FootprintController.js - About 1 hr to fix

                    Function createResponse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      createResponse: function(req, res, next) {
                        const response = (data) => {
                    
                          return new Promise((resolve, reject) => {
                            if (!data) {
                    Severity: Minor
                    Found in lib/utils.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 update has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      update(req, res) {
                        const FootprintService = this.app.services.FootprintService
                        const options = this.app.packs.express.getOptionsFromQuery(req.query)
                        const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
                        const id = req.params.id
                    Severity: Minor
                    Found in api/controllers/FootprintController.js - About 1 hr 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

                        Avoid deeply nested control flow statements.
                        Open

                                      if (joinedA > joinedB) {
                                        return asc ? 1 : -1
                                      }
                        Severity: Major
                        Found in lib/utils.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if (joinedA < joinedB) {
                                          return asc ? -1 : 1
                                        }
                          Severity: Major
                          Found in lib/utils.js - About 45 mins 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

                            Avoid too many return statements within this function.
                            Open

                                            return asc ? 1 : -1
                            Severity: Major
                            Found in lib/utils.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return asc ? -1 : 1
                              Severity: Major
                              Found in lib/utils.js - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language