Gapminder/vizabi

View on GitHub
src/models/marker.js

Summary

Maintainability
F
5 days
Test Coverage

File marker.js has 694 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as utils from "base/utils";
import Model from "base/model";

/*!
 * HOOK MODEL
Severity: Major
Found in src/models/marker.js - About 1 day to fix

    Marker has 46 functions (exceeds 20 allowed). Consider refactoring.
    Open

    const Marker = Model.extend({
    
      getClassDefaults() {
        const defaults = {
          select: [],
    Severity: Minor
    Found in src/models/marker.js - About 6 hrs to fix

      Function getFrames has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getFrames(forceFrame, selected) {
          const _this = this;
          if (!this.cachedFrames) this.cachedFrames = {};
      
          const KEYS = utils.unique(this._getAllDimensions({ exceptType: "time" }));
      Severity: Major
      Found in src/models/marker.js - About 4 hrs to fix

        Function getKeys has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getKeys(KEYS) {
            const _this = this;
            let resultKeys;
        
            KEYS = KEYS || utils.unique(this._getAllDimensions({ exceptType: "time" }));
        Severity: Major
        Found in src/models/marker.js - About 2 hrs to fix

          Function getEntityLimits has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getEntityLimits(entity) {
              const _this = this;
              const timePoints = this._parent.time.getAllSteps();
              const selectedEdgeTimes = [];
              const hooks = [];
          Severity: Major
          Found in src/models/marker.js - About 2 hrs to fix

            Function cachePath has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  this.frameQueues[cachePath] = new Promise((resolve, reject) => {
            
                    _this.partialResult[cachePath] = {};
                    _this.partialResult[cachePath].timeOrConstantHooks = [];
                    steps.forEach(t => { _this.partialResult[cachePath][t] = {}; });
            Severity: Minor
            Found in src/models/marker.js - About 1 hr to fix

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

                getFrame(time, cb, keys) {
                  //keys = null;
                  const _this = this;
                  if (!this.cachedFrames) this.cachedFrames = {};
              
              
              Severity: Minor
              Found in src/models/marker.js - About 1 hr to fix

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

                  getFrames(forceFrame, selected) {
                    const _this = this;
                    if (!this.cachedFrames) this.cachedFrames = {};
                
                    const KEYS = utils.unique(this._getAllDimensions({ exceptType: "time" }));
                Severity: Minor
                Found in src/models/marker.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 getFrame has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  getFrame(time, cb, keys) {
                    //keys = null;
                    const _this = this;
                    if (!this.cachedFrames) this.cachedFrames = {};
                
                
                Severity: Minor
                Found in src/models/marker.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 setSpace has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  setSpace(newSpace) {
                    const subHooks = Object.keys(this.getSubhooks(true));
                    const setProps = {};
                    const setWhichProps = {};
                    const newDimModels = setProps["space"] = this._root.dimensionManager.getDimensionModelsForSpace(this._space, newSpace);
                Severity: Minor
                Found in src/models/marker.js - About 1 hr to fix

                  Function listenFramesQueue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    listenFramesQueue(keys, cb) {
                      const _this = this;
                      const KEYS = utils.unique(this._getAllDimensions({ exceptType: "time" }));
                      const TIME = this._getFirstDimension({ type: "time" });
                      const steps = this._parent.time.getAllSteps();
                  Severity: Minor
                  Found in src/models/marker.js - About 1 hr to fix

                    Function _interpolateBetweenFrames has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _interpolateBetweenFrames(time, nextFrameIndex, steps, cb, keys) {
                        const _this = this;
                    
                        if (nextFrameIndex == 0) {
                          //getFrame makes sure the frane is ready because a frame with non-existing data might be adressed
                    Severity: Minor
                    Found in src/models/marker.js - About 1 hr to fix

                      Function getEntityLimits has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getEntityLimits(entity) {
                          const _this = this;
                          const timePoints = this._parent.time.getAllSteps();
                          const selectedEdgeTimes = [];
                          const hooks = [];
                      Severity: Minor
                      Found in src/models/marker.js - About 55 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

                      Function init has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        init(name, value, parent, binds, persistent) {
                      Severity: Minor
                      Found in src/models/marker.js - About 35 mins to fix

                        Function _interpolateBetweenFrames has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          _interpolateBetweenFrames(time, nextFrameIndex, steps, cb, keys) {
                        Severity: Minor
                        Found in src/models/marker.js - About 35 mins to fix

                          Function getAvailableConcept has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            getAvailableConcept({ index: index = 0, type: type = null, includeOnlyIDs: includeOnlyIDs = [], excludeIDs: excludeIDs = [] } = { }) {
                              if (!type && includeOnlyIDs.length == 0 && excludeIDs.length == 0) {
                                return null;
                              }
                          
                          
                          Severity: Minor
                          Found in src/models/marker.js - About 35 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

                          Avoid too many return statements within this function.
                          Open

                                  return null;
                          Severity: Major
                          Found in src/models/marker.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return null;
                            Severity: Major
                            Found in src/models/marker.js - About 30 mins to fix

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

                                isHighlighted(d) {
                                  const _this = this;
                                  const value = JSON.stringify(this._createValue(d));
                                  return this.highlight
                                    .map(d => JSON.stringify(_this._createValue(d)) === value)
                              Severity: Major
                              Found in src/models/marker.js and 1 other location - About 2 hrs to fix
                              src/models/marker.js on lines 239..246

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

                              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

                                isSelected(d) {
                                  const _this = this;
                                  const value = JSON.stringify(this._createValue(d));
                              
                                  return this.select
                              Severity: Major
                              Found in src/models/marker.js and 1 other location - About 2 hrs to fix
                              src/models/marker.js on lines 322..328

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

                              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

                                getAvailableConcept({ index: index = 0, type: type = null, includeOnlyIDs: includeOnlyIDs = [], excludeIDs: excludeIDs = [] } = { }) {
                                  if (!type && includeOnlyIDs.length == 0 && excludeIDs.length == 0) {
                                    return null;
                                  }
                              
                              
                              Severity: Minor
                              Found in src/models/marker.js and 1 other location - About 35 mins to fix
                              src/models/data.js on lines 262..273

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

                              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

                                      if (hook._type === "label" && hook.getEntity().dim === key) {
                                        names.label = name;
                                      }
                              Severity: Minor
                              Found in src/models/marker.js and 1 other location - About 30 mins to fix
                              src/models/marker.js on lines 376..378

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

                              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

                                      if (hook._type !== "label" && hook.getEntity().dim === key) {
                                        names.key = name;
                                      }
                              Severity: Minor
                              Found in src/models/marker.js and 1 other location - About 30 mins to fix
                              src/models/marker.js on lines 373..375

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

                              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