Gapminder/vizabi

View on GitHub
src/helpers/d3.colorPicker.js

Summary

Maintainability
D
2 days
Test Coverage

File d3.colorPicker.js has 419 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isTouchDevice } from "base/utils";

const css = {
  INVISIBLE: "vzb-invisible",
  COLOR_POINTER: "vzb-colorpicker-pointer",
Severity: Minor
Found in src/helpers/d3.colorPicker.js - About 6 hrs to fix

    Function _initCircles has 109 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _initCircles() {
        const {
          _svg,
          _maxHeight,
          _width,
    Severity: Major
    Found in src/helpers/d3.colorPicker.js - About 4 hrs to fix

      ColorPicker has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class ColorPicker {
        constructor(container) {
          this._container = container;
          this._wrapper = this._container.select("." + css.COLOR_PICKER);
      
      
      Severity: Minor
      Found in src/helpers/d3.colorPicker.js - About 3 hrs to fix

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

          fitToScreen(arg) {
            const screen = this._container.node().getBoundingClientRect();
            let xPos, yPos;
        
            const {
        Severity: Minor
        Found in src/helpers/d3.colorPicker.js - About 1 hr to fix

          Function _initVariables has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _initVariables() {
              // radius of the central hole in color wheel: px
              this._maxWidth = 280;
              this._maxHeight = 323;
          
          
          Severity: Minor
          Found in src/helpers/d3.colorPicker.js - About 1 hr to fix

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

              _generateColorData() {
                const {
                  _minL,
                  _minH,
                  _nCellsL,
            Severity: Minor
            Found in src/helpers/d3.colorPicker.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 _generateColorData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _generateColorData() {
                const {
                  _minL,
                  _minH,
                  _nCellsL,
            Severity: Minor
            Found in src/helpers/d3.colorPicker.js - About 1 hr to fix

              Function fitToScreen has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                fitToScreen(arg) {
                  const screen = this._container.node().getBoundingClientRect();
                  let xPos, yPos;
              
                  const {
              Severity: Minor
              Found in src/helpers/d3.colorPicker.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 resize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                resize(arg) {
                  if (!arguments.length)
                    return;
              
                  if (typeof arg !== "undefined") {
              Severity: Minor
              Found in src/helpers/d3.colorPicker.js - About 1 hr to fix

                There are no issues that match your filters.

                Category
                Status