matteozambon89/trailpack-koa

View on GitHub

Showing 84 of 84 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  destroy(ctx, next) {
    if (ctx.params.id && !_.isEmpty(this.query)) {
      throw Boom.preconditionFailed(this.__('errors.footprints.destroy.mutex'))
    }

Severity: Major
Found in api/policies/FootprintPolicy.js and 2 other locations - About 1 hr to fix
api/policies/FootprintPolicy.js on lines 55..61
api/policies/FootprintPolicy.js on lines 106..112

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 72.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  updateAssociation(ctx, next) {
    if (ctx.params.childId && !_.isEmpty(this.query)) {
      throw Boom.preconditionFailed(this.__('errors.footprints.update.mutex'))
    }

Severity: Major
Found in api/policies/FootprintPolicy.js and 2 other locations - About 1 hr to fix
api/policies/FootprintPolicy.js on lines 55..61
api/policies/FootprintPolicy.js on lines 67..73

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 72.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  update(ctx, next) {
    if (ctx.params.id && !_.isEmpty(this.query)) {
      throw Boom.preconditionFailed(this.__('errors.footprints.update.mutex'))
    }

Severity: Major
Found in api/policies/FootprintPolicy.js and 2 other locations - About 1 hr to fix
api/policies/FootprintPolicy.js on lines 67..73
api/policies/FootprintPolicy.js on lines 106..112

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 72.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

              if (app.config.web.spdy && app.config.web.ssl) {
                const spdyParams = _.merge(
                  app.config.web.spdy,
                  app.config.web.ssl
                )
        Severity: Major
        Found in lib/server.js and 1 other location - About 1 hr to fix
        lib/server.js on lines 224..241

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 67.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                else if (app.config.web.https && app.config.web.ssl) {
                  const httpsParams = _.merge(
                    app.config.web.https,
                    app.config.web.ssl
                  )
          Severity: Major
          Found in lib/server.js and 1 other location - About 1 hr to fix
          lib/server.js on lines 215..241

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 67.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              conflictPack (app, reject) {
                reject = reject || Promise.reject
            
                const message = lib.Utils.message('error-conflict-pack')
                const err = new Error(message)
            Severity: Major
            Found in lib/error.js and 1 other location - About 1 hr to fix
            lib/error.js on lines 41..48

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              missingKoa (app, reject) {
                reject = reject || Promise.reject
            
                const message = lib.Utils.message('error-missing-koa')
                const err = new Error(message)
            Severity: Major
            Found in lib/error.js and 1 other location - About 1 hr to fix
            lib/error.js on lines 25..32

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              unhandledClusterSocketType (app, reject) {
                reject = reject || Promise.reject
            
                const message = lib.Utils.message('error-unhandled-cluster-socket-type')
                const err = new Error(message)
            Severity: Major
            Found in lib/error.js and 1 other location - About 1 hr to fix
            lib/error.js on lines 115..122

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 62.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              unhandledSocketType (app, reject) {
                reject = reject || Promise.reject
            
                const message = lib.Utils.message('error-unhandled-socket-type')
                const err = new Error(message)
            Severity: Major
            Found in lib/error.js and 1 other location - About 1 hr to fix
            lib/error.js on lines 123..130

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 62.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                if (id) {
                  response = FootprintService.find(ctx.params.model, id, options)
                }
                else {
                  response = FootprintService.find(ctx.params.model, criteria, options)
            Severity: Major
            Found in api/controllers/FootprintController.js and 1 other location - About 1 hr to fix
            api/controllers/FootprintController.js on lines 129..134

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                if (id) {
                  response = FootprintService.destroy(ctx.params.model, id, options)
                }
                else {
                  response = FootprintService.destroy(ctx.params.model, criteria, options)
            Severity: Major
            Found in api/controllers/FootprintController.js and 1 other location - About 1 hr to fix
            api/controllers/FootprintController.js on lines 60..65

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 61.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                  if (result.error) {
                    const message = lib.Utils.message('warn-malformed-route-cors', route.path)
                    app.logger.warn(message)
                    app.logger.verbose('warn-malformed-route-cors', route, result)
                  }
            Severity: Major
            Found in lib/server.js and 2 other locations - About 1 hr to fix
            lib/server.js on lines 475..488
            lib/server.js on lines 496..507

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                    if (result.error) {
                      const message = lib.Utils.message('warn-malformed-route-redirect', route.path)
                      app.logger.warn(message)
                      app.logger.verbose('warn-malformed-route-redirect', route, result)
                    }
            Severity: Major
            Found in lib/server.js and 2 other locations - About 1 hr to fix
            lib/server.js on lines 452..459
            lib/server.js on lines 475..488

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                    if (result.error) {
                      const message = lib.Utils.message('warn-malformed-route-serve', route.path)
                      app.logger.warn(message)
                      app.logger.verbose('warn-malformed-route-serve', route, result)
                    }
            Severity: Major
            Found in lib/server.js and 2 other locations - About 1 hr to fix
            lib/server.js on lines 452..459
            lib/server.js on lines 496..507

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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
              Severity
              Category
              Status
              Source
              Language