Gapminder/vizabi

View on GitHub
src/base/utils.js

Summary

Maintainability
F
1 wk
Test Coverage

File utils.js has 1070 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import interpolator from "vizabi-interpolators/interpolators";


export const d3json = function(path, callback) {
  d3.json(path)
Severity: Major
Found in src/base/utils.js - About 2 days to fix

    Function comparePlainObjects has a Cognitive Complexity of 46 (exceeds 5 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: Minor
    Found in src/base/utils.js - About 7 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 matchAny has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    export const matchAny = function(values, compare, wildc) {
      //normalize value
      if (!isArray(values)) values = [values];
      if (!wildc) wildc = "*"; //star by default
      let match = false;
    Severity: Minor
    Found in src/base/utils.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 interpolatePoint has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      export const interpolatePoint = function(items, use, which, next, dimTime, time, method, extrapolate) {
      
      
        if (!items || items.length === 0) {
          warn("interpolatePoint failed because incoming array is empty. It was " + which);
      Severity: Minor
      Found in src/base/utils.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 firstBy has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export function firstBy() {
      
        function identity(v) {
          return v;
        }
      Severity: Minor
      Found in src/base/utils.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 ajax has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export const ajax = function(options) {
        const request = new XMLHttpRequest();
        request.open(options.method, options.url, true);
        if (options.method === "POST" && !options.json) {
          request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
      Severity: Minor
      Found in src/base/utils.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 getBrowserDetails has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getBrowserDetails = () => {
      
        const nVer = navigator.appVersion;
        const nAgt = navigator.userAgent;
        let browserName = navigator.appName;
      Severity: Minor
      Found in src/base/utils.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 getBrowserDetails has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const getBrowserDetails = () => {
      
        const nVer = navigator.appVersion;
        const nAgt = navigator.userAgent;
        let browserName = navigator.appName;
      Severity: Minor
      Found in src/base/utils.js - About 1 hr to fix

        Function preventAncestorScrolling has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const preventAncestorScrolling = function(element) {
          let preventScrolling = false;
          element.on("mousewheel", function(d, i) {
            const scrollTop = this.scrollTop;
            const scrollHeight = this.scrollHeight;
        Severity: Minor
        Found in src/base/utils.js - About 1 hr to fix

          Function forEach has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          export const forEach = function(obj, callback, ctx) {
            if (!obj) {
              return;
            }
            let i, size;
          Severity: Minor
          Found in src/base/utils.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 firstBy has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function firstBy() {
          
            function identity(v) {
              return v;
            }
          Severity: Minor
          Found in src/base/utils.js - About 1 hr to fix

            Function deepExtend has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const deepExtend = function(/*obj_1, [obj_2], [obj_N]*/) {
              if (arguments.length < 1 || typeof arguments[0] !== "object") {
                return false;
              }
            
            
            Severity: Minor
            Found in src/base/utils.js - About 1 hr to fix

              Function deepArrayEquals has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export const deepArrayEquals = function(a, b) {
                if (a === b) return true;
                if (a == null || b == null) return false;
                if (a.length != b.length) return false;
                for (let i = 0; i < a.length; ++i) {
              Severity: Minor
              Found in src/base/utils.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 nestArrayToObjWithFlatKeys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export const nestArrayToObjWithFlatKeys = function(arr, res = {}, keys, key = "") {
                if (!arr || !arr.length || !arr[0].key) {
                  if (keys) {
                    keys += "]";
                    !res[keys] && (res[keys] = {});
              Severity: Minor
              Found in src/base/utils.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 matchAny has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const matchAny = function(values, compare, wildc) {
                //normalize value
                if (!isArray(values)) values = [values];
                if (!wildc) wildc = "*"; //star by default
                let match = false;
              Severity: Minor
              Found in src/base/utils.js - About 1 hr to fix

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

                export const interpolatePoint = function(items, use, which, next, dimTime, time, method, extrapolate) {
                
                
                  if (!items || items.length === 0) {
                    warn("interpolatePoint failed because incoming array is empty. It was " + which);
                Severity: Minor
                Found in src/base/utils.js - About 1 hr to fix

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

                  export const diffObject = function(obj2, obj1) {
                    const diff = {};
                    forEach(obj1, (value, key) => {
                      if (!obj2.hasOwnProperty(key) && isPlainObject(value)) {
                        diff[key] = diffObject({}, value);
                  Severity: Minor
                  Found in src/base/utils.js - About 1 hr to fix

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

                    export const throttle = function(func, ms) {
                    
                      let throttled = false;
                      let savedArgs;
                      let savedThis;
                    Severity: Minor
                    Found in src/base/utils.js - About 1 hr to fix

                      Function interpolatePoint has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      export const interpolatePoint = function(items, use, which, next, dimTime, time, method, extrapolate) {
                      Severity: Major
                      Found in src/base/utils.js - About 1 hr to fix

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

                        export const getOSname = () => {
                          let OSName = "Unknown";
                          if (window.navigator.userAgent.indexOf("Windows NT 10.0") != -1) OSName = "Windows 10";
                          if (window.navigator.userAgent.indexOf("Windows NT 6.2")  != -1) OSName = "Windows 8";
                          if (window.navigator.userAgent.indexOf("Windows NT 6.1")  != -1) OSName = "Windows 7";
                        Severity: Minor
                        Found in src/base/utils.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 filter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const filter = function(arr, filter) {
                          let index = -1;
                          const length = arr.length;
                          let resIndex = -1;
                          const result = [];
                        Severity: Minor
                        Found in src/base/utils.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 filterAny has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const filterAny = function(arr, filter, wildcard) {
                          let index = -1;
                          const length = arr.length;
                          let resIndex = -1;
                          const result = [];
                        Severity: Minor
                        Found in src/base/utils.js - About 45 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 deeply nested control flow statements.
                        Open

                                  if (value >= min && value <= max) {
                                    found = i;
                                    break;
                                  }
                        Severity: Major
                        Found in src/base/utils.js - About 45 mins to fix

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

                          export const post = function(url, pars, success, error, json) {
                          Severity: Minor
                          Found in src/base/utils.js - About 35 mins to fix

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

                            export const get = function(url, pars, success, error, json) {
                            Severity: Minor
                            Found in src/base/utils.js - About 35 mins to fix

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

                              export const arrayEquals = function(a, b) {
                                if (a === b) return true;
                                if (a == null || b == null) return false;
                                if (a.length != b.length) return false;
                                for (let i = 0; i < a.length; ++i) {
                              Severity: Minor
                              Found in src/base/utils.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

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

                              export const memoize = function(fn) {
                                return function() {
                                  const args = Array.prototype.slice.call(arguments);
                                  let hash = "";
                                  let i = args.length;
                              Severity: Minor
                              Found in src/base/utils.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/base/utils.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                  return true;
                                Severity: Major
                                Found in src/base/utils.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                    return result;
                                  Severity: Major
                                  Found in src/base/utils.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        if (time - items[items.length - 1][dimTime] >= 0) return items[items.length - 1][which];
                                    Severity: Major
                                    Found in src/base/utils.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                        return true;
                                      Severity: Major
                                      Found in src/base/utils.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                            if (time < items[0][dimTime] || time > items[items.length - 1][dimTime]) return null;
                                        Severity: Major
                                        Found in src/base/utils.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                            if (next === 0) return items[0][which];
                                          Severity: Major
                                          Found in src/base/utils.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                } else if (a[i] !== b[i]) return false;
                                            Severity: Major
                                            Found in src/base/utils.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  return true;
                                              Severity: Major
                                              Found in src/base/utils.js - About 30 mins to fix

                                                Function error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                Open

                                                export const error = function(err) {
                                                  if (console && typeof console.error === "function") {
                                                    if (err.stack) {
                                                      console.error(err.stack);
                                                    } else {
                                                Severity: Minor
                                                Found in src/base/utils.js - About 25 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

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

                                                  if ((verOffset = nAgt.indexOf("Opera")) != -1) {
                                                    browserName = "Opera";
                                                    fullVersion = nAgt.substring(verOffset + 6);
                                                    if ((verOffset = nAgt.indexOf("Version")) != -1)
                                                      fullVersion = nAgt.substring(verOffset + 8);
                                                Severity: Major
                                                Found in src/base/utils.js and 1 other location - About 1 hr to fix
                                                src/base/utils.js on lines 1641..1660

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

                                                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

                                                  else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
                                                    browserName = "Safari";
                                                    fullVersion = nAgt.substring(verOffset + 7);
                                                    if ((verOffset = nAgt.indexOf("Version")) != -1)
                                                      fullVersion = nAgt.substring(verOffset + 8);
                                                Severity: Major
                                                Found in src/base/utils.js and 1 other location - About 1 hr to fix
                                                src/base/utils.js on lines 1624..1660

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

                                                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

                                                export const d3json = function(path, callback) {
                                                  d3.json(path)
                                                    .then(response => callback(null, response))
                                                    .catch(error => callback(error));
                                                };
                                                Severity: Major
                                                Found in src/base/utils.js and 1 other location - About 1 hr to fix
                                                src/base/utils.js on lines 10..14

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

                                                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

                                                export const d3text = function(path, callback) {
                                                  d3.text(path)
                                                    .then(response => callback(null, response))
                                                    .catch(error => callback(error));
                                                };
                                                Severity: Major
                                                Found in src/base/utils.js and 1 other location - About 1 hr to fix
                                                src/base/utils.js on lines 4..8

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

                                                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

                                                    const prevent = function() {
                                                      d3.event.stopPropagation();
                                                      d3.event.preventDefault();
                                                      d3.event.returnValue = false;
                                                      return false;
                                                Severity: Minor
                                                Found in src/base/utils.js and 1 other location - About 40 mins to fix
                                                src/components/timeslider/timeslider.js on lines 262..267

                                                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

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

                                                export const arrayMin = function(arr) {
                                                  return arr.reduce((p, v) => (p < v ? p : v));
                                                };
                                                Severity: Minor
                                                Found in src/base/utils.js and 1 other location - About 35 mins to fix
                                                src/base/utils.js on lines 1064..1066

                                                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

                                                export const arrayMax = function(arr) {
                                                  return arr.reduce((p, v) => (p > v ? p : v));
                                                };
                                                Severity: Minor
                                                Found in src/base/utils.js and 1 other location - About 35 mins to fix
                                                src/base/utils.js on lines 1056..1058

                                                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

                                                There are no issues that match your filters.

                                                Category
                                                Status