Gapminder/vizabi

View on GitHub
src/components/colorlegend/colorlegend.js

Summary

Maintainability
F
1 wk
Test Coverage

Function _updateRainbowLegend has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
Open

  _updateRainbowLegend(isVisible) {
    const _this = this;

    //Hide rainbow element if showing minimap or if color is discrete
    this.rainbowEl.classed("vzb-hidden", !isVisible);
Severity: Minor
Found in src/components/colorlegend/colorlegend.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 colorlegend.js has 601 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as utils from "base/utils";
import Component from "base/component";
import ColorPicker from "helpers/d3.colorPicker";
import axisSmart from "helpers/d3.axisWithLabelPicker";
import { close as iconClose } from "base/iconset";
Severity: Major
Found in src/components/colorlegend/colorlegend.js - About 1 day to fix

    Function _updateRainbowLegend has 207 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _updateRainbowLegend(isVisible) {
        const _this = this;
    
        //Hide rainbow element if showing minimap or if color is discrete
        this.rainbowEl.classed("vzb-hidden", !isVisible);
    Severity: Major
    Found in src/components/colorlegend/colorlegend.js - About 1 day to fix

      Function _interact has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        _interact() {
          const _this = this;
          const KEYS = this.KEYS;
          const KEY = this.KEY;
          const which = this.which;
      Severity: Minor
      Found in src/components/colorlegend/colorlegend.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 _interact has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _interact() {
          const _this = this;
          const KEYS = this.KEYS;
          const KEY = this.KEY;
          const which = this.which;
      Severity: Major
      Found in src/components/colorlegend/colorlegend.js - About 3 hrs to fix

        Function init has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          init(config, context) {
            const _this = this;
            this.template = '<div class="vzb-cl-outer"></div>';
            this.name = "colorlegend";
        
        
        Severity: Minor
        Found in src/components/colorlegend/colorlegend.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 init has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          init(config, context) {
            const _this = this;
            this.template = '<div class="vzb-cl-outer"></div>';
            this.name = "colorlegend";
        
        
        Severity: Major
        Found in src/components/colorlegend/colorlegend.js - About 2 hrs to fix

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

                  .on("start", function start(d, i) {
                    //click сompatible node raise
                    let nextSibling = this.nextSibling;
                    while (nextSibling) {
                      this.parentNode.insertBefore(nextSibling, this);
          Severity: Major
          Found in src/components/colorlegend/colorlegend.js - About 2 hrs to fix

            Function _updateListLegend has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _updateListLegend(isVisible) {
            
                this.listColorsEl.classed("vzb-hidden", !isVisible);
                if (!isVisible) return;
            
            
            Severity: Minor
            Found in src/components/colorlegend/colorlegend.js - About 1 hr to fix

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

                _updateMinimapLegend(isVisible) {
              
                  this.minimapEl.classed("vzb-hidden", !isVisible);
                  if (!isVisible) return;
              
              
              Severity: Minor
              Found in src/components/colorlegend/colorlegend.js - About 1 hr to fix

                Function ready has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  ready() {
                    this.KEYS = utils.unique(this.model.marker._getAllDimensions({ exceptType: "time" }));
                    this.KEY = this.colorModel._getFirstDimension();
                    this.markerArray = this.model.marker.getKeys();
                    this.which = this.colorModel.which;
                Severity: Minor
                Found in src/components/colorlegend/colorlegend.js - About 1 hr to fix

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

                        "change:time.end": function(evt, original) {
                          if (!_this._readyOnce || _this.model.time.splash) return;
                          if (_this.colorModel.which == _this.model.time.dim) {
                            _this.ready();
                          }
                  Severity: Major
                  Found in src/components/colorlegend/colorlegend.js and 1 other location - About 2 hrs to fix
                  src/components/colorlegend/colorlegend.js on lines 59..64

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

                  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

                        "change:time.start": function(evt, original) {
                          if (!_this._readyOnce || _this.model.time.splash) return;
                          if (_this.colorModel.which == _this.model.time.dim) {
                            _this.ready();
                          }
                  Severity: Major
                  Found in src/components/colorlegend/colorlegend.js and 1 other location - About 2 hrs to fix
                  src/components/colorlegend/colorlegend.js on lines 65..70

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

                  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

                      this.removeElseButton.on("click", () => {
                        this._interact().clickToShow(...args);
                        this._closeSelectDialog();
                      });
                  Severity: Major
                  Found in src/components/colorlegend/colorlegend.js and 2 other locations - About 50 mins to fix
                  src/components/colorlegend/colorlegend.js on lines 170..173
                  src/components/colorlegend/colorlegend.js on lines 180..183

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

                  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

                      this.selectAllButton.on("click", () => {
                        this._interact().clickToSelect(...args);
                        this._closeSelectDialog();
                      });
                  Severity: Major
                  Found in src/components/colorlegend/colorlegend.js and 2 other locations - About 50 mins to fix
                  src/components/colorlegend/colorlegend.js on lines 175..178
                  src/components/colorlegend/colorlegend.js on lines 180..183

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

                  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

                      this.editColorButton.on("click", () => {
                        this._interact().clickToChangeColor(...args);
                        this._closeSelectDialog();
                      });
                  Severity: Major
                  Found in src/components/colorlegend/colorlegend.js and 2 other locations - About 50 mins to fix
                  src/components/colorlegend/colorlegend.js on lines 170..173
                  src/components/colorlegend/colorlegend.js on lines 175..178

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

                  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