pacificclimate/climate-explorer-frontend

View on GitHub

Showing 120 of 355 total issues

File InformationItems.js has 700 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Central resource for LabelWithInfo and Information items used throughout
// the app.

import React from "react";
import { Link } from "react-router-dom";
Severity: Major
Found in src/components/guidance-content/info/InformationItems.js - About 1 day to fix

    File util-test.js has 501 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /********************************************************
     * util-test.js - tests for the functions in util.js
     *
     * There is one test (sometimes multiple parts) for each
     * function in ../util.js. The tests have the same names as
    Severity: Major
    Found in src/core/__tests__/util-test.js - About 1 day to fix

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

      /* **********************************************************************
       * chart-generators.js - functions that generate a C3 chart specification
       * object from backend query results and metadata describing the query.
       *
       * The three primary functions in this file are:
      Severity: Minor
      Found in src/core/chart-generators.js - About 7 hrs to fix

        Function DualAnnualCycleGraph has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function DualAnnualCycleGraph({
          model_id,
          experiment,
          variable_id,
          meta,
        Severity: Minor
        Found in src/components/graphs/DualAnnualCycleGraph.js - About 5 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function render has 136 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render() {
            const filteredMetaVariable = this.filterMetaBy(
              "model",
              "scenario",
              "variable",
        Severity: Major
        Found in src/components/app-controllers/DualAppController/DualAppController.js - About 5 hrs to fix

          File chart-generator-tests.js has 382 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* ***************************************************************
           * chart-generator-tests.js - tests for chart generation functions
           *
           * One test (sometimes with multiple parts) for each function in
           * chart-generator-tests.js. The tests have the same names and are
          Severity: Minor
          Found in src/core/__tests__/chart-generator-tests.js - About 5 hrs to fix

            Function render has 122 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render() {
                const filteredMetaVariable = this.filterMetaBy(
                  "model",
                  "scenario",
                  "variable",

              Function render has 113 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                render() {
                  const filteredMeta = this.filterMetaBy("model", "scenario", "variable");
                  const filteredPercentileMeta = this.filterPercentileMetaBy(
                    "model",
                    "scenario",

                Function render has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    const filteredMeta = this.filterMetaBy("model", "scenario", "variable");
                    const modelContextMetadata = this.filterMetaBy("scenario", "variable");
                
                    const model_id = this.representativeValue("model", "model_id");

                  Function render has 102 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    render() {
                      const metaToKeyedData = (m) => ({
                        key: `${m.ensemble_member} ${m.start_date}-${m.end_date}`,
                        ...m,
                      });

                    File util.js has 335 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /***********************************************************
                     * util.js - a collection of data-handling functions
                     ***********************************************************/
                    
                    import moment from "moment/moment";
                    Severity: Minor
                    Found in src/core/util.js - About 4 hrs to fix

                      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 assignDataToYAxis has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function assignDataToYAxis(graph, seriesMetadata, groupByUnits = false) {
                          // get sorting algorithm, if the chart already has one.
                          const sortingParams = {
                            y: axisSortingParams(graph, "y"),
                            y2: axisSortingParams(graph, "y2"),
                        Severity: Minor
                        Found in src/core/chart-generators.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 render has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          render() {
                            // TODO: Add positioning for autoset
                        
                            const dataLayers = DataMap.layerTypes.map(
                              (layerType) =>
                        Severity: Major
                        Found in src/components/DataMap/DataMap.js - About 3 hrs to fix

                          File sample-API-results.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          /*********************************************************************
                           * sample-API-results.js - sample data for testing.
                           *
                           * A collection of objects representing sample results from the
                           * climate explorer backend API, used to test data validation, graph
                          Severity: Minor
                          Found in src/core/__test_data__/sample-API-results.js - About 3 hrs to fix

                            Function render has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              render() {
                                const mapLegend = (
                                  <MapLegend
                                    {...this.props}
                                    {...this.state}
                            Severity: Major
                            Found in src/components/map-controllers/DualMapController/DualMapController.js - About 3 hrs to fix

                              Function render has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                render() {
                                  // TODO: Extract this to a separate component
                                  const LayerVisibilityButton = ({ layerVisibility, onClick }) => (
                                    <Button bsSize={"xsmall"} onClick={onClick}>
                                      <Glyphicon glyph={layerVisibility ? "eye-open" : "eye-close"} />
                              Severity: Major
                              Found in src/components/LayerOpacityControl/LayerOpacityControl.js - About 3 hrs to fix

                                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

                                  Function exportDataToWorksheet has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  var exportDataToWorksheet = function (
                                    datatype,
                                    metadata,
                                    data,
                                    format,
                                  Severity: Major
                                  Found in src/core/export.js - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language