Gapminder/vizabi

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

Summary

Maintainability
F
1 wk
Test Coverage

File timeslider.js has 554 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as utils from "base/utils";
import Component from "base/component";
import axisSmart from "helpers/d3.axisWithLabelPicker";

const precision = 1;
Severity: Major
Found in src/components/timeslider/timeslider.js - About 1 day to fix

    Function _updateProgressBar has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

      _updateProgressBar(time) {
        const _this = this;
        if (time) {
          if (_this.completedTimeFrames.indexOf(time) != -1) return;
          _this.completedTimeFrames.push(time);
    Severity: Minor
    Found in src/components/timeslider/timeslider.js - About 5 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 a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

      init(model, context) {
    
        this.name = "gapminder-timeslider";
        this.template = this.template || require("./timeslider.html");
        this.prevPosition = null;
    Severity: Minor
    Found in src/components/timeslider/timeslider.js - About 4 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 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      init(model, context) {
    
        this.name = "gapminder-timeslider";
        this.template = this.template || require("./timeslider.html");
        this.prevPosition = null;
    Severity: Major
    Found in src/components/timeslider/timeslider.js - About 3 hrs to fix

      Function readyOnce has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        readyOnce() {
      
          const _this = this;
      
          //DOM to d3
      Severity: Major
      Found in src/components/timeslider/timeslider.js - About 2 hrs to fix

        Function _updateProgressBar has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _updateProgressBar(time) {
            const _this = this;
            if (time) {
              if (_this.completedTimeFrames.indexOf(time) != -1) return;
              _this.completedTimeFrames.push(time);
        Severity: Major
        Found in src/components/timeslider/timeslider.js - About 2 hrs to fix

          Function updateSize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            updateSize(range) {
              if (this.model.time.splash) return;
          
              this.model.time.pause();
          
          
          Severity: Minor
          Found in src/components/timeslider/timeslider.js - About 1 hr to fix

            Function _setHandle has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _setHandle(transition) {
                const _this = this;
                const value = this.model.time.value;
                //this.slide.call(this.brush.extent([value, value]));
                const new_pos = this.xScale(value);
            Severity: Minor
            Found in src/components/timeslider/timeslider.js - About 1 hr to fix

              Function _getBrushed has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _getBrushed() {
                  const _this = this;
                  return function() {
              
                    if (_this.model.time.playing)
              Severity: Minor
              Found in src/components/timeslider/timeslider.js - About 1 hr to fix

                Function setSelectedLimits has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  setSelectedLimits(force) {
                    const _this = this;
                    this._setSelectedLimitsId++;
                    const _setSelectedLimitsId = this._setSelectedLimitsId;
                
                
                Severity: Minor
                Found in src/components/timeslider/timeslider.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (i + 1 < _this.availableTimeFrames.length && next - _this.availableTimeFrames[i + 1][0] == 0) {
                                _this.availableTimeFrames[i][1] = _this.availableTimeFrames[i + 1][1];
                                _this.availableTimeFrames.splice(i + 1, 1);
                              } else {
                                _this.availableTimeFrames[i][1] = next;
                  Severity: Major
                  Found in src/components/timeslider/timeslider.js - About 45 mins to fix

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

                      updateSelectedStartLimiter() {
                        const _this = this;
                        this.select.select("#clip-start-" + _this._id).remove();
                        this.select.select(".selected-start").remove();
                        if (this.model.time.startSelected && this.model.time.startSelected > this.model.time.start) {
                    Severity: Major
                    Found in src/components/timeslider/timeslider.js and 1 other location - About 1 day to fix
                    src/components/timeslider/timeslider.js on lines 470..483

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

                    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

                      updateSelectedEndLimiter() {
                        const _this = this;
                        this.select.select("#clip-end-" + _this._id).remove();
                        this.select.select(".selected-end").remove();
                        if (this.model.time.endSelected && this.model.time.endSelected < this.model.time.end) {
                    Severity: Major
                    Found in src/components/timeslider/timeslider.js and 1 other location - About 1 day to fix
                    src/components/timeslider/timeslider.js on lines 455..468

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

                    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, path) {
                            if (_this.slide) {
                              //only set handle position if change is external
                              if (!_this.model.time.dragging) _this._setHandle(_this.model.time.playing);
                              _this.ready();
                    Severity: Major
                    Found in src/components/timeslider/timeslider.js and 1 other location - About 2 hrs to fix
                    src/components/timeslider/timeslider.js on lines 108..114

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

                    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.end": function(evt, path) {
                            if (_this.slide) {
                              //only set handle position if change is external
                              if (!_this.model.time.dragging) _this._setHandle(_this.model.time.playing);
                              _this.ready();
                    Severity: Major
                    Found in src/components/timeslider/timeslider.js and 1 other location - About 2 hrs to fix
                    src/components/timeslider/timeslider.js on lines 101..107

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

                    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

                        this.model_expects = [{
                          name: "time",
                          type: "time"
                        }, {
                          name: "marker",
                    Severity: Minor
                    Found in src/components/timeslider/timeslider.js and 1 other location - About 45 mins to fix
                    src/components/buttonlist/buttonlist.js on lines 33..42

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

                    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

                          if (_this.model.time.dragging) {
                            d3.event.stopPropagation();
                            d3.event.preventDefault();
                            d3.event.returnValue = false;
                            return false;
                    Severity: Minor
                    Found in src/components/timeslider/timeslider.js and 1 other location - About 40 mins to fix
                    src/base/utils.js on lines 757..762

                    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

                    There are no issues that match your filters.

                    Category
                    Status