lib/shared/Configurator.js

Summary

Maintainability
F
5 days
Test Coverage

Function _handleObject has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

  _handleObject(obj, path = [], checkOnly = false) {
    let show = false;
    let filter = this.options.filter;
    let visibleInSet = false;
    for (let subObj in obj) {
Severity: Minor
Found in lib/shared/Configurator.js - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File Configurator.js has 479 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var util = require('../util');

var ColorPicker = require('./ColorPicker').default;

/**
Severity: Minor
Found in lib/shared/Configurator.js - About 7 hrs to fix

    Function setOptions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      setOptions(options) {
        if (options !== undefined) {
          // reset the popup history because the indices may have been changed.
          this.popupHistory = {};
          this._removePopup();
    Severity: Minor
    Found in lib/shared/Configurator.js - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Configurator has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Configurator {
      /**
       * @param {Object} parentModule        | the location where parentModule.setOptions() can be called
       * @param {Object} defaultContainer    | the default container of the module
       * @param {Object} configureOptions    | the fully configured and predefined options set found in allOptions.js
    Severity: Minor
    Found in lib/shared/Configurator.js - About 2 hrs to fix

      Function _handleObject has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _handleObject(obj, path = [], checkOnly = false) {
          let show = false;
          let filter = this.options.filter;
          let visibleInSet = false;
          for (let subObj in obj) {
      Severity: Major
      Found in lib/shared/Configurator.js - About 2 hrs to fix

        Function _create has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          _create() {
            this._clean();
            this.changedOptions = [];
        
            let filter = this.options.filter;
        Severity: Minor
        Found in lib/shared/Configurator.js - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _makeRange has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _makeRange(arr, value, path) {
            let defaultValue = arr[0];
            let min = arr[1];
            let max = arr[2];
            let step = arr[3];
        Severity: Minor
        Found in lib/shared/Configurator.js - About 1 hr to fix

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

            _create() {
              this._clean();
              this.changedOptions = [];
          
              let filter = this.options.filter;
          Severity: Minor
          Found in lib/shared/Configurator.js - About 1 hr to fix

            Function setOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              setOptions(options) {
                if (options !== undefined) {
                  // reset the popup history because the indices may have been changed.
                  this.popupHistory = {};
                  this._removePopup();
            Severity: Minor
            Found in lib/shared/Configurator.js - About 1 hr to fix

              Function _constructOptions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                _constructOptions(value, path, optionsObj = {}) {
                  let pointer = optionsObj;
              
                  // when dropdown boxes can be string or boolean, we typecast it into correct types
                  value = value === 'true'  ? true  : value;
              Severity: Minor
              Found in lib/shared/Configurator.js - About 1 hr 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 _makeCheckbox has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                _makeCheckbox(defaultValue, value, path) {
                  var checkbox = document.createElement('input');
                  checkbox.type = 'checkbox';
                  checkbox.className = 'vis-configuration vis-config-checkbox';
                  checkbox.checked = defaultValue;
              Severity: Minor
              Found in lib/shared/Configurator.js - About 1 hr 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 _makeRange has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                _makeRange(arr, value, path) {
                  let defaultValue = arr[0];
                  let min = arr[1];
                  let max = arr[2];
                  let step = arr[3];
              Severity: Minor
              Found in lib/shared/Configurator.js - About 1 hr 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 _handleArray has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                _handleArray(arr, value, path) {
                  if (typeof arr[0] === 'string' && arr[0] === 'color') {
                    this._makeColorField(arr, value, path);
                    if (arr[1] !== value) {this.changedOptions.push({path:path, value:value});}
                  }
              Severity: Minor
              Found in lib/shared/Configurator.js - About 1 hr 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

              Avoid deeply nested control flow statements.
              Open

                          if (path.indexOf('physics') !== -1) {
                            if (this.moduleOptions.physics.solver !== subObj) {
                              draw = false;
                            }
                          }
              Severity: Major
              Found in lib/shared/Configurator.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (!(item instanceof Array) && typeof item !== 'string' && typeof item !== 'boolean' && item instanceof Object) {
                              this.allowCreation = false;
                              show = this._handleObject(item, newPath, true);
                              this.allowCreation = checkOnly === false;
                            }
                Severity: Major
                Found in lib/shared/Configurator.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (draw === true) {
                                // initially collapse options with an disabled enabled option.
                                if (item.enabled !== undefined) {
                                  let enabledPath = util.copyAndExtendArray(newPath, 'enabled');
                                  let enabledValue = this._getValue(enabledPath);
                  Severity: Major
                  Found in lib/shared/Configurator.js - About 45 mins to fix

                    Function _makeDropdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      _makeDropdown(arr, value, path) {
                        let select = document.createElement('select');
                        select.className = 'vis-configuration vis-config-select';
                        let selectedValue = 0;
                        if (value !== undefined) {
                    Severity: Minor
                    Found in lib/shared/Configurator.js - About 25 mins 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

                    TODO found
                    Open

                        // TODO: Add some error handling and remove this lint exception
                    Severity: Minor
                    Found in lib/shared/Configurator.js by fixme

                    There are no issues that match your filters.

                    Category
                    Status