getlackey/lackey-cms

View on GitHub
modules/core/server/controllers/crud.injection.js

Summary

Maintainability
D
3 days
Test Coverage

File crud.injection.js has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* jslint esnext:true, node:true */
/* globals LACKEY_PATH */
'use strict';
/*
    Copyright 2016 Enigma Marketing Services Limited
Severity: Minor
Found in modules/core/server/controllers/crud.injection.js - About 3 hrs to fix

    CRUDInjectionController has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CRUDInjectionController {
    
        static get field() {
            throw new Error('You have to override this method');
        }
    Severity: Minor
    Found in modules/core/server/controllers/crud.injection.js - About 3 hrs to fix

      Function table has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static table(model, req, res) {
      
              let restParams = req.getRESTQuery(true),
                  isExport = req.__resFormat === 'xlsx',
                  self = this,
      Severity: Major
      Found in modules/core/server/controllers/crud.injection.js - About 2 hrs to fix

        Function mapActions has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static mapActions(actions, columns, rows, rowAction) {
                let
                    self = this;
                if (rows) {
                    rows.forEach((row) => {
        Severity: Minor
        Found in modules/core/server/controllers/crud.injection.js - About 1 hr to fix

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

              static removeTaxonomy(Taxonomy, req, res) {
                  let self = this;
                  this
                      .taxonomyFromQuery(Taxonomy, {
                          type: req.taxonomyTypeName,
          Severity: Major
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 5 hrs to fix
          modules/cms/server/controllers/content.js on lines 215..231

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

          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 (action.href) {
                                          action.href = self.populateAction(action.href, row, columns);
                                      } else if (action.api) {
                                          action.api = self.populateAction(action.api, row, columns);
                                      }
          Severity: Major
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 1 hr to fix
          modules/core/server/controllers/crud.injection.js on lines 291..295

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

          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 (_rowAction.href) {
                                  _rowAction.href = self.populateAction(_rowAction.href, row, columns);
                              } else if (_rowAction.api) {
                                  _rowAction.api = self.populateAction(_rowAction.api, row, columns);
                              }
          Severity: Major
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 1 hr to fix
          modules/core/server/controllers/crud.injection.js on lines 277..281

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

          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

              static overrideGetter(field, handler) {
                  this.__overrides = this.__overrides || {};
                  this.__overrides[field] = this.__overrides[field] || [];
                  this.__overrides[field].push(handler);
              }
          Severity: Major
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 1 hr to fix
          modules/cms/client/js/emit.js on lines 25..29

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

          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

                                      rows: data.rows.map(row => row.columns.map(column => column.value !== undefined ? column.value : ''))
          Severity: Major
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 1 hr to fix
          modules/analytics/server/controllers/dashboard.js on lines 58..58

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

          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

                  req[this.field]
                      .update(req.body)
                      .then(instance => {
                          res.api(instance);
          
          
          Severity: Minor
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 40 mins to fix
          modules/core/server/controllers/crud.injection.js on lines 144..151

          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

                  model
                      .create(req.body)
                      .then(instance => {
                          res.api(instance);
                      }, error => {
          Severity: Minor
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 40 mins to fix
          modules/core/server/controllers/crud.injection.js on lines 171..179

          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

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

                      }, error => {
                          console.error(error.message);
                          console.error(error.stack);
                          return res.error(error);
                      });
          Severity: Minor
          Found in modules/core/server/controllers/crud.injection.js and 1 other location - About 40 mins to fix
          modules/cms/server/controllers/user.js on lines 184..188

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

          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

          There are no issues that match your filters.

          Category
          Status