matteozambon89/trailpack-koa

View on GitHub

Showing 14 of 84 total issues

Function _generateKoaRoute has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  _generateKoaRoute (app, koa, router, route) {
    // Make sure url params are defined as:
    // :x
    // instead of
    // {x}
Severity: Minor
Found in lib/server.js - About 3 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 _createWebServer has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _createWebServer(app, koa) {
    return new Promise((resolve, reject) => {
      let nativeServer
      let serverType

Severity: Major
Found in lib/server.js - About 3 hrs to fix

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

    /**
     * @Author: Matteo Zambon <Matteo>
     * @Date:   2018-02-15 09:55:24
     * @Last modified by:   Matteo
     * @Last modified time: 2018-02-18 04:43:44
    Severity: Minor
    Found in lib/server.js - About 3 hrs to fix

      Function _generateKoaRoute has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _generateKoaRoute (app, koa, router, route) {
          // Make sure url params are defined as:
          // :x
          // instead of
          // {x}
      Severity: Major
      Found in lib/server.js - About 2 hrs to fix

        Function registerFeatures has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          registerFeatures (app, koa) {
            // Set onError handler, if function is specified
            if (typeof app.config.web.onError === 'function') {
              koa.context.onerror = app.config.web.onError
            }
        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

        File FootprintController.js has 278 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * @Author: Matteo Zambon <Matteo>
         * @Date:   2018-02-12 11:41:41
         * @Last modified by:   Matteo
         * @Last modified time: 2018-02-18 01:20:29
        Severity: Minor
        Found in api/controllers/FootprintController.js - About 2 hrs to fix

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

            updateAssociation(ctx, next) {
              const req = ctx.request
          
              const FootprintService = this.app.services.FootprintService
              const options = this.app.packs.koa.getOptionsFromQuery(this.query)
          Severity: Minor
          Found in api/controllers/FootprintController.js - About 1 hr to fix

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

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

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

                registerFeatures (app, koa) {
                  // Set onError handler, if function is specified
                  if (typeof app.config.web.onError === 'function') {
                    koa.context.onerror = app.config.web.onError
                  }
              Severity: Minor
              Found in lib/server.js - About 1 hr to fix

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

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

                  Function _registerRoutes has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _registerRoutes(app, koa) {
                      // Reverse routes to have parametrized routes first
                      const routes = app.routes.reverse()
                  
                      const router = new KoaRouter()
                  Severity: Minor
                  Found in lib/server.js - About 1 hr to fix

                    Function update has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      update(ctx, next) {
                        const req = ctx.request
                    
                        const FootprintService = this.app.services.FootprintService
                        const options = this.app.packs.koa.getOptionsFromQuery(this.query)
                    Severity: Minor
                    Found in api/controllers/FootprintController.js - About 1 hr to fix

                      Function find has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        find(ctx, next) {
                          const FootprintService = this.app.services.FootprintService
                          const options = this.app.packs.koa.getOptionsFromQuery(this.query)
                          const criteria = this.app.packs.koa.getCriteriaFromQuery(this.query)
                          const id = ctx.params.id
                      Severity: Minor
                      Found in api/controllers/FootprintController.js - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                if (!customMiddlewares) {
                                  return
                                }
                        Severity: Major
                        Found in lib/server.js - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language