pacificclimate/climate-explorer-frontend

View on GitHub

Showing 97 of 339 total issues

File InformationItems.js has 661 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 chart-generators.js has 417 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 6 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, comparand_id, comparandMeta, area }
      ) {
        function getMetadata(dataSpec) {
          // Find and return metadata matching the data specification (`dataSpec`):
      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 131 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

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

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

            render() {
              const filteredMetaVariable =
                this.filterMetaBy('model', 'scenario', 'variable');
              const filteredMetaComparand =
                this.filterMetaBy('model', 'scenario', 'comparand');

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

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

              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');

                File util-test.js has 342 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: Minor
                Found in src/core/__tests__/util-test.js - About 4 hrs to fix

                  File chart-generator-tests.js has 324 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 3 hrs to fix

                    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 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.
                    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 render has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      render() {
                        // TODO: Add positioning for autoset
                    
                        const dataLayers = DataMap.layerTypes.map(layerType => (
                          this.props[layerType] && (
                    Severity: Major
                    Found in src/components/DataMap/DataMap.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}
                            hasValidComparand={hasValidData('comparand', this.props)}
                      Severity: Major
                      Found in src/components/map-controllers/DualMapController/DualMapController.js - About 3 hrs to fix

                        Function render has 79 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 render has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            render() {
                              return (
                                <div id={'table'}>
                                  <BootstrapTable
                                    data={this.props.data}
                          Severity: Major
                          Found in src/components/DataTable/DataTable.js - About 2 hrs to fix

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

                              render() {
                                const mapLegend = (<MapLegend
                                  {...this.props}
                                  {...this.state}
                                  hasValidComparand={hasValidData('comparand', this.props)}

                              Function makeVariableResponseGraph has 70 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 2 hrs to fix

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

                                  render() {
                                    function countsByGroup(meta, grouper) {
                                      const groupedByPropName = _.groupBy(meta, grouper);
                                      const countsByPropValue = _.map(groupedByPropName, (group, key) => (
                                        { key, count: group.length }

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

                                    render() {
                                      // TODO: Improve returned item
                                      if (!_.allDefined(this.props, 'model_id', 'experiment', 'variable_id')) {
                                        return 'Readying...';
                                      }
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language