matteozambon89/trailpack-koa

View on GitHub
api/controllers/FootprintController.js

Summary

Maintainability
F
6 days
Test Coverage

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 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 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

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

                  response.then(elements => {
                    if (!elements) {
                      throw Boom.notFound('Not Found')
                    }
                    ctx.body = elements || {}
              Severity: Major
              Found in api/controllers/FootprintController.js and 1 other location - About 6 hrs to fix
              api/controllers/FootprintController.js on lines 67..83

              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 171.

              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

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

                  response.then(elements => {
                    if (!elements) {
                      throw Boom.notFound('Not Found')
                    }
                    ctx.body = elements || {}
              Severity: Major
              Found in api/controllers/FootprintController.js and 1 other location - About 6 hrs to fix
              api/controllers/FootprintController.js on lines 210..226

              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 171.

              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

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

                  response.then(elements => {
                    ctx.body = elements || {}
                    next()
                  }).catch(err => {
                    if (err.code == 'E_VALIDATION') {
              Severity: Major
              Found in api/controllers/FootprintController.js and 3 other locations - About 5 hrs to fix
              api/controllers/FootprintController.js on lines 106..119
              api/controllers/FootprintController.js on lines 261..274
              api/controllers/FootprintController.js on lines 305..318

              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 151.

              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

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

                  response.then(elements => {
                    ctx.body = elements || {}
                    next()
                  }).catch(err => {
                    if (err.code == 'E_VALIDATION') {
              Severity: Major
              Found in api/controllers/FootprintController.js and 3 other locations - About 5 hrs to fix
              api/controllers/FootprintController.js on lines 106..119
              api/controllers/FootprintController.js on lines 136..149
              api/controllers/FootprintController.js on lines 261..274

              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 151.

              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

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

                  response.then(elements => {
                    ctx.body = elements || {}
                    next()
                  }).catch(err => {
                    if (err.code == 'E_VALIDATION') {
              Severity: Major
              Found in api/controllers/FootprintController.js and 3 other locations - About 5 hrs to fix
              api/controllers/FootprintController.js on lines 136..149
              api/controllers/FootprintController.js on lines 261..274
              api/controllers/FootprintController.js on lines 305..318

              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 151.

              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

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

                  response.then(elements => {
                    ctx.body = elements || {}
                    next()
                  }).catch(err => {
                    if (err.code == 'E_VALIDATION') {
              Severity: Major
              Found in api/controllers/FootprintController.js and 3 other locations - About 5 hrs to fix
              api/controllers/FootprintController.js on lines 106..119
              api/controllers/FootprintController.js on lines 136..149
              api/controllers/FootprintController.js on lines 305..318

              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 151.

              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 2 locations. Consider refactoring.
              Open

                  if (childId) {
                    response = FootprintService.findAssociation(
                      parentModel,
                      parentId,
                      childAttribute,
              Severity: Minor
              Found in api/controllers/FootprintController.js and 1 other location - About 40 mins to fix
              api/controllers/FootprintController.js on lines 286..303

              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 49.

              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 (childId) {
                    response = FootprintService.destroyAssociation(
                      parentModel,
                      parentId,
                      childAttribute,
              Severity: Minor
              Found in api/controllers/FootprintController.js and 1 other location - About 40 mins to fix
              api/controllers/FootprintController.js on lines 191..208

              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 49.

              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

              Parsing error: The keyword 'const' is reserved
              Open

              const Boom = require('boom')

              For more information visit Source: http://eslint.org/docs/rules/

              There are no issues that match your filters.

              Category
              Status