pacificclimate/climate-explorer-frontend

View on GitHub

Showing 358 of 358 total issues

Function fadeSeriesByRank has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function fadeSeriesByRank(graph, ranker) {
  let rankDictionary = {};

  for (let column of graph.data.columns) {
    const seriesName = column[0];
Severity: Minor
Found in src/core/chart-formatters.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 getMetadata has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function getMetadata() {
    const {
      model_id,
      experiment,
      variable_id,
Severity: Minor
Found in src/components/graphs/DualTimeSeriesGraph.js - About 1 hr to fix

    Function render has 27 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...";
        }

      Function render has 27 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...";
          }

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

          constructor(props) {
            super(props);
        
            this.state = {
              run: undefined,

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

            loadGraph() {
              // Fetch data for graph, then convert it to a graph spec and set state
              // accordingly.
          
              if (!shouldLoadData(this.props, this.displayNoDataMessage)) {

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

              function getMetadata(dataSpec) {
                // Find and return metadata matching the data specification (`dataSpec`):
                // model_id, experiment, variable_id, start_date, end_date, ensemble_member
                // for monthly, seasonal and annual timescales.
                // Variable, model, and experiment are supplied by the graph's parent, but
            Severity: Minor
            Found in src/components/graphs/DualAnnualCycleGraph.js - About 1 hr to fix

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

                it("accepts a valid watershed", function () {
                  expect(util.validateWatershedData({ data: mockAPI.watershed })).toEqual({
                    data: mockAPI.watershed,
                  });
                });
              Severity: Major
              Found in src/core/__tests__/util-test.js and 4 other locations - About 1 hr to fix
              src/core/__tests__/util-test.js on lines 175..179
              src/core/__tests__/util-test.js on lines 225..229
              src/core/__tests__/util-test.js on lines 230..234
              src/core/__tests__/util-test.js on lines 235..239

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

              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 5 locations. Consider refactoring.
              Open

                it("accepts valid yearly resolution data", function () {
                  expect(
                    util.validateAnnualCycleData({ data: mockAPI.annualTasmaxTimeseries }),
                  ).toEqual({ data: mockAPI.annualTasmaxTimeseries });
                });
              Severity: Major
              Found in src/core/__tests__/util-test.js and 4 other locations - About 1 hr to fix
              src/core/__tests__/util-test.js on lines 175..179
              src/core/__tests__/util-test.js on lines 225..229
              src/core/__tests__/util-test.js on lines 230..234
              src/core/__tests__/util-test.js on lines 321..325

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

              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 5 locations. Consider refactoring.
              Open

                it("accepts valid datasets", function () {
                  expect(util.validateStatsData({ data: mockAPI.tasmaxStats })).toEqual({
                    data: mockAPI.tasmaxStats,
                  });
                });
              Severity: Major
              Found in src/core/__tests__/util-test.js and 4 other locations - About 1 hr to fix
              src/core/__tests__/util-test.js on lines 225..229
              src/core/__tests__/util-test.js on lines 230..234
              src/core/__tests__/util-test.js on lines 235..239
              src/core/__tests__/util-test.js on lines 321..325

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

              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 5 locations. Consider refactoring.
              Open

                it("accepts valid monthly resolution data", function () {
                  expect(
                    util.validateAnnualCycleData({ data: mockAPI.monthlyTasmaxTimeseries }),
                  ).toEqual({ data: mockAPI.monthlyTasmaxTimeseries });
                });
              Severity: Major
              Found in src/core/__tests__/util-test.js and 4 other locations - About 1 hr to fix
              src/core/__tests__/util-test.js on lines 175..179
              src/core/__tests__/util-test.js on lines 230..234
              src/core/__tests__/util-test.js on lines 235..239
              src/core/__tests__/util-test.js on lines 321..325

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

              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 5 locations. Consider refactoring.
              Open

                it("accepts valid seasonal resolution data", function () {
                  expect(
                    util.validateAnnualCycleData({ data: mockAPI.seasonalTasmaxTimeseries }),
                  ).toEqual({ data: mockAPI.seasonalTasmaxTimeseries });
                });
              Severity: Major
              Found in src/core/__tests__/util-test.js and 4 other locations - About 1 hr to fix
              src/core/__tests__/util-test.js on lines 175..179
              src/core/__tests__/util-test.js on lines 225..229
              src/core/__tests__/util-test.js on lines 235..239
              src/core/__tests__/util-test.js on lines 321..325

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

              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

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

              var createTimeseriesWorksheetSummaryCells = function (metadata, dataSpec) {
                var rows = [];
                var header = [
                  "Model",
                  "Emissions Scenario",
              Severity: Minor
              Found in src/core/export.js - About 1 hr to fix

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

                export function getStats() {
                  return Promise.resolve({
                    data: {
                      foo: {
                        min: 0.06095475000006445,
                Severity: Minor
                Found in src/data-services/__mocks__/ce-backend.js - About 1 hr to fix

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

                  export function layersToGeoJSON(collectionType, layers) {
                    // Convert an array of Leaflet layers to GeoJSON according to
                    // argument `collectionType`:
                    //
                    //  - `'FeatureCollection'`: a GeoJSON FeatureCollection.
                  Severity: Minor
                  Found in src/core/geoJSON-leaflet.js - About 1 hr to fix

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

                      autoscale: function () {
                        /*
                         * Get min/max for current view then update layer params
                         */
                        this.layers.forEach((layer) => {
                    Severity: Minor
                    Found in src/core/leaflet-ncwms-autoset-colorscale.js - About 1 hr to fix

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

                        render() {
                          return (
                            <div className={styles.selectorframe}>
                              <ControlLabel
                                className={
                      Severity: Minor
                      Found in src/components/Selector/Selector.js - About 1 hr to fix

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

                          render() {
                            const center = _.pick(this.props.origin, "lat", "lng");
                            return (
                              <Map
                                crs={this.props.crs}
                        Severity: Minor
                        Found in src/components/CanadaBaseMap/CanadaBaseMap.js - About 1 hr to fix

                          Identical blocks of code found in 4 locations. Consider refactoring.
                          Open

                            componentDidUpdate(prevProps, prevState) {
                              if (!this.state.fetchingData && this.state.data === null) {
                                this.fetchData();
                              }
                            }
                          Severity: Major
                          Found in src/components/graphs/AnnualCycleGraph/AnnualCycleGraph.js and 3 other locations - About 1 hr to fix
                          src/components/StatisticalSummaryTable/StatisticalSummaryTable.js on lines 97..101
                          src/components/WatershedSummaryTable/WatershedSummaryTable.js on lines 71..75
                          src/components/graphs/LongTermAveragesGraph/LongTermAveragesGraph.js on lines 124..128

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

                          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

                              for (let i = 0; i < 3; i++) {
                                if (series[0].search(resolutions[i]) != -1) {
                                  return i;
                                }
                              }
                          Severity: Major
                          Found in src/core/__tests__/chart-formatter-tests.js and 1 other location - About 1 hr to fix
                          src/components/graphs/SingleAnnualCycleGraph.js on lines 49..53

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language