Gapminder/vizabi

View on GitHub

Showing 540 of 540 total issues

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

      const filtered = items.reduce((filtered, d) => {

        // check for dates
        const f = (utils.isDate(d[attr])) ? d[attr] : parseFloat(d[attr]);

Severity: Major
Found in src/models/hook.js and 1 other location - About 3 hrs to fix
src/base/datastorage.js on lines 328..340

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

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

    const filtered = items.reduce((filtered, d) => {

      // check for dates
      const f = (utils.isDate(d[attr])) ? d[attr] : parseFloat(d[attr]);

Severity: Major
Found in src/base/datastorage.js and 1 other location - About 3 hrs to fix
src/models/hook.js on lines 592..604

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

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

Function checkTimeLimits has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  checkTimeLimits() {
    //if all hooks are ready, check time limits and set time model to ready
    if ([...this.hooksToListen].every(hook => hook._ready)) {
      const minArray = [this.startOrigin], maxArray = [this.endOrigin];
      if (!this.showForecast) maxArray.push(this.endBeforeForecast);
Severity: Minor
Found in src/models/time.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 _enableSearch has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  _enableSearch() {
    const _this = this;

    const input = this.wrapper.select("." + css.search);

Severity: Minor
Found in src/components/treemenu/treemenu.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 comparePlainObjects has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const comparePlainObjects = function(a, b) {

  //Returns the object's class, Array, Date, RegExp, Object are of interest to us
  const getClass = function(val) {
    return Object.prototype.toString.call(val)
Severity: Major
Found in src/base/utils.js - About 3 hrs to fix

    Function resize has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      resize() {
    
        const _this = this;
    
        this.profiles = {
    Severity: Major
    Found in src/tools/barchart/barchart-component.js - About 3 hrs to fix

      Function highlightValueRun has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          axis.highlightValueRun = function(g) {
      
            //if viewport is defined and HL value is outside then behave as reset HL
            if (options.viewportLength && highlightValue != "none" && (
              axis.scale()(highlightValue) > options.viewportLength ||
      Severity: Major
      Found in src/helpers/d3.axisWithLabelPicker.js - About 3 hrs to fix

        Labels has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        const Labels = Class.extend({
        
          init(context, conditions) {
            const _this = this;
            this.context = context;
        Severity: Minor
        Found in src/helpers/labels.js - About 3 hrs to fix

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

            validate() {
          
              //check if time start and end are not defined but start and end origins are defined
              if (this.start == null && this.startOrigin) this.set("start", this.startOrigin, null, false);
              if (this.end == null && this.endOrigin) this.set("end", this.endOrigin, null, false);
          Severity: Minor
          Found in src/models/time.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 positionLabel has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            positionLabel(d, index, cache, context, duration, showhide, lineGroup, position) {
              const KEY = this.KEY;
              const cached = cache || this.cached[d[KEY]];
          
              const lockPosition = (position || position === 0);
          Severity: Major
          Found in src/helpers/labels.js - About 2 hrs to fix

            Function resolver has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function resolver(g) {
                  if (selector == null) {
                    console.warn("D3 collision resolver stopped: missing a CSS slector");
                    return;
                  }
            Severity: Major
            Found in src/helpers/d3.collisionResolver.js - About 2 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 init has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  init(config, context) {
                
                    this.name = "gapminder-indicatorpicker";
                    this.template = '<span class="vzb-ip-holder"><span class="vzb-ip-select"></span><span class="vzb-ip-info"></span></span>';
                
                
                Severity: Major
                Found in src/components/indicatorpicker/indicatorpicker.js - About 2 hrs to fix

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

                            labelGroup
                              .style("opacity", 1)
                              .transition().duration(duration).ease(d3.easeExp)
                              .style("opacity", 0)
                              .on("end", () => {
                  Severity: Major
                  Found in src/helpers/labels.js and 1 other location - About 2 hrs to fix
                  src/helpers/labels.js on lines 254..262

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

                  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

                            lineGroup
                              .style("opacity", 1)
                              .transition().duration(duration).ease(d3.easeExp)
                              .style("opacity", 0)
                              .on("end", () => {
                  Severity: Major
                  Found in src/helpers/labels.js and 1 other location - About 2 hrs to fix
                  src/helpers/labels.js on lines 245..253

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

                  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

                  Function label has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function label(container, isTooltip) {
                        container
                          .each(function(d, index) {
                            const view = d3.select(this);
                  
                  
                  Severity: Major
                  Found in src/helpers/labels.js - About 2 hrs to fix

                    Menu has 24 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    const Menu = Class.extend({
                      init(parent, menu, options) {
                        const _this = this;
                        this.parent = parent;
                        this.OPTIONS = options;
                    Severity: Minor
                    Found in src/components/treemenu/treemenu.js - About 2 hrs to fix

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

                              if (d3.event.selection && d3.event.selection[0] == d3.event.selection[1]) {
                                const brushDatum = _this.sliderEl.node().__brush;
                                brushDatum.selection[1][0] += 0.01;
                              }
                      Severity: Major
                      Found in src/components/brushslider/brushslider.js and 1 other location - About 2 hrs to fix
                      src/components/brushslider/brushslider.js on lines 167..170

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

                      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 (d3.event.selection && d3.event.selection[0] == d3.event.selection[1]) {
                                const brushDatum = _this.sliderEl.node().__brush;
                                brushDatum.selection[1][0] += 0.01;
                              }
                      Severity: Major
                      Found in src/components/brushslider/brushslider.js and 1 other location - About 2 hrs to fix
                      src/components/brushslider/brushslider.js on lines 159..162

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

                      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

                      Function repositionLabelsThatStickOut has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function repositionLabelsThatStickOut(tickValues, options, orient, scale, dimension) {
                            if (!tickValues) return null;
                            const result = {};
                      
                            // make an abstraction layer for margin sizes
                      Severity: Major
                      Found in src/helpers/d3.axisWithLabelPicker.js - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language