pacificclimate/climate-explorer-frontend

View on GitHub
src/core/chart-transformers.js

Summary

Maintainability
D
2 days
Test Coverage

Function makeVariableResponseGraph has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function makeVariableResponseGraph(x, y, graph) {
  let c3Data = {};

  const seriesNameContains = function (series, keyword) {
    return caseInsensitiveStringSearch(series[0], keyword);
Severity: Major
Found in src/core/chart-transformers.js - About 3 hrs to fix

    Function makeAnomalyGraph has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    function makeAnomalyGraph(base, variable_id, graph) {
      //anomalies for some variables are typically expressed as percentages.
      //if this is a single variable graph, check the variable configuration
      //to see if this is one of them; if so, display percentages on the chart.
      const displayPercent =
    Severity: Minor
    Found in src/core/chart-transformers.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 makeAnomalyGraph has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function makeAnomalyGraph(base, variable_id, graph) {
      //anomalies for some variables are typically expressed as percentages.
      //if this is a single variable graph, check the variable configuration
      //to see if this is one of them; if so, display percentages on the chart.
      const displayPercent =
    Severity: Major
    Found in src/core/chart-transformers.js - About 3 hrs to fix

      File chart-transformers.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /************************************************************************
       * chart-transformers.js - functions that accept a C3 chart specification
       *   for a timeseries chart and alter the data to produce a different
       *   type of chart.
       *
      Severity: Minor
      Found in src/core/chart-transformers.js - About 2 hrs to fix

        Function addAnomalyTooltipFormatter has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function addAnomalyTooltipFormatter(oldFormatter, baseSeries, displayPercent) {
          const newTooltipValueFormatter = function (value, ratio, id, index) {
            let nominal = oldFormatter(value, ratio, id, index);
            if (_.isUndefined(nominal)) {
              //this series doesn't display in tooltip.
        Severity: Minor
        Found in src/core/chart-transformers.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 makeVariableResponseGraph has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        function makeVariableResponseGraph(x, y, graph) {
          let c3Data = {};
        
          const seriesNameContains = function (series, keyword) {
            return caseInsensitiveStringSearch(series[0], keyword);
        Severity: Minor
        Found in src/core/chart-transformers.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 makeTimeSliceGraph has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function makeTimeSliceGraph(timestamp, graph) {
          let slicedData = [];
          let timestamps = [];
          let sliceIndex = -1;
        
        
        Severity: Minor
        Found in src/core/chart-transformers.js - About 1 hr to fix

          Function makeTimeSliceGraph has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function makeTimeSliceGraph(timestamp, graph) {
            let slicedData = [];
            let timestamps = [];
            let sliceIndex = -1;
          
          
          Severity: Minor
          Found in src/core/chart-transformers.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

          There are no issues that match your filters.

          Category
          Status