getlackey/lackey-cms

View on GitHub
modules/cms/client/js/manager/structure.ui.js

Summary

Maintainability
F
1 wk
Test Coverage

File structure.ui.js has 740 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint no-cond-assign:0, no-new:0, no-unused-vars:0 */
/* jslint browser:true, node:true, esnext:true */
'use strict';
/*
    Copyright 2016 Enigma Marketing Services Limited
Severity: Major
Found in modules/cms/client/js/manager/structure.ui.js - About 1 day to fix

    StructureUI has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class StructureUI extends Emitter {
    
        /**
         * Gets template meta data
         * @param   {string} templatePath
    Severity: Minor
    Found in modules/cms/client/js/manager/structure.ui.js - About 4 hrs to fix

      Function mapDictionary has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          mapDictionary(data) {
              data.dictionary = Object
                  .keys(data.dictionary)
                  .map(key => {
                      let value = data.dictionary[key];
      Severity: Minor
      Found in modules/cms/client/js/manager/structure.ui.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 buildUI has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          buildUI() {
      
              let
                  self = this,
                  ignore = lackey.select('[data-lky-hook="header.settings"]')[0].getAttribute('data-lky-ignore').split(',');
      Severity: Major
      Found in modules/cms/client/js/manager/structure.ui.js - About 2 hrs to fix

        Function mapDictionary has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            mapDictionary(data) {
                data.dictionary = Object
                    .keys(data.dictionary)
                    .map(key => {
                        let value = data.dictionary[key];
        Severity: Major
        Found in modules/cms/client/js/manager/structure.ui.js - About 2 hrs to fix

          Function dictionary has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      .map(key => {
                          let value = data.dictionary[key];
                          if (Array.isArray(value)) {
                              return {
                                  type: 'select',
          Severity: Minor
          Found in modules/cms/client/js/manager/structure.ui.js - About 2 hrs to fix

            Function drawDimensions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                drawDimensions() {
            
                    let
                        self = this,
                        context,
            Severity: Minor
            Found in modules/cms/client/js/manager/structure.ui.js - About 1 hr to fix

              Function inspect has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  inspect(path, templatePath) {
                      let
                          structureController,
                          context,
                          data,
              Severity: Minor
              Found in modules/cms/client/js/manager/structure.ui.js - About 1 hr to fix

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

                    drawMeta() {
                        let self = this;
                
                        return this.options
                            .context()
                Severity: Minor
                Found in modules/cms/client/js/manager/structure.ui.js - About 1 hr to fix

                  Function bindMetaEvents has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      bindMetaEvents(responses) {
                          let settings = responses[0],
                              context = responses[2];
                          let self = this;
                          lackey
                  Severity: Minor
                  Found in modules/cms/client/js/manager/structure.ui.js - About 1 hr to fix

                    Function drawSections has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        drawSections() {
                            let
                                context,
                                self = this;
                    
                    
                    Severity: Minor
                    Found in modules/cms/client/js/manager/structure.ui.js - About 1 hr to fix

                      Function bindLayout has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          bindLayout() {
                              var self = this,
                                  sectionsRoot = lackey.hook('settings.blocks', self.node),
                                  blocksContainer = lackey.hook('sections', sectionsRoot),
                                  layoutContainer = lackey.hook('layout', sectionsRoot);
                      Severity: Minor
                      Found in modules/cms/client/js/manager/structure.ui.js - About 1 hr to fix

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

                            moveBlock(blockElement, beforeBlockElement) {
                                let self = this,
                                    parentPath = blockElement.getAttribute('data-lky-parent'),
                                    blockIndex = parseInt(blockElement.getAttribute('data-lky-index')),
                                    blockPath = parentPath + '.' + blockIndex,
                        Severity: Minor
                        Found in modules/cms/client/js/manager/structure.ui.js - About 1 hr to fix

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

                              pickUser(settings, event, hook) {
                                  this.collapse();
                                  let self = this,
                                      user = hook.getAttribute('data-value');
                          
                          
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 5 hrs to fix
                          modules/cms/client/js/manager/structure.ui.js on lines 698..713

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

                          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

                              pickDateTime(settings, event, hook) {
                                  this.collapse();
                                  let self = this,
                                      date = hook.getAttribute('data-value');
                          
                          
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 5 hrs to fix
                          modules/cms/client/js/manager/structure.ui.js on lines 715..730

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

                          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

                              toggle(event) {
                                  event.preventDefault();
                                  event.stopPropagation();
                          
                                  let toOpen = event.target.getAttribute('data-lky-open'),
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 3 hrs to fix
                          modules/cms/client/js/manager/gallery.ui.js on lines 355..368

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

                          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

                                              try {
                                                  data.publishAt = responses[2].publishAt;
                                                  data.publishAtFormatted = dateformat(new Date(responses[2].publishAt));
                                              } catch (e) {
                                                  console.error(e);
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 1 hr to fix
                          modules/cms/client/js/manager/structure.ui.js on lines 605..610

                          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

                                              try {
                                                  data.createdAt = responses[2].createdAt;
                                                  data.createdAtFormatted = dateformat(new Date(responses[2].createdAt));
                                              } catch (e) {
                                                  console.error(e);
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 1 hr to fix
                          modules/cms/client/js/manager/structure.ui.js on lines 611..616

                          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

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

                              fadeIn() {
                                  return new Promise(resolve => {
                                      let self = this;
                          
                                      setTimeout(() => {
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 1 hr to fix
                          modules/cms/client/js/manager/picker.ui.js on lines 109..119

                          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

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

                                                  items: value.map((item) => {
                                                      if (typeof item === 'string') {
                                                          return {
                                                              label: item,
                                                              value: item
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 1 hr to fix
                          modules/cms/client/js/manager/structure.ui.js on lines 888..897

                          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

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

                                                  items: value.items.map((item) => {
                                                      if (typeof item === 'string') {
                                                          return {
                                                              label: item,
                                                              value: item
                          Severity: Major
                          Found in modules/cms/client/js/manager/structure.ui.js and 1 other location - About 1 hr to fix
                          modules/cms/client/js/manager/structure.ui.js on lines 872..881

                          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

                          There are no issues that match your filters.

                          Category
                          Status