pacificclimate/climate-explorer-frontend

View on GitHub

Showing 358 of 358 total issues

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

    var applyLabelStyle = function (el) {
      el.style.position = "absolute";
      el.style.right = this.options.width + "px";
    }.bind(this);
src/core/leaflet-ncwms-colorbar.js on lines 65..68

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

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

      ([layerType, opacity]) => {
        const visible = this.state.layerState[layerType].visible;
        return (
          <Row key={layerType} className="layer-controls">
            <Row>
Severity: Minor
Found in src/components/LayerOpacityControl/LayerOpacityControl.js - About 1 hr to fix

    Function refreshValues has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      refreshValues: function () {
        /*
         * Source new values from the ncWMS server. Possible future breakage due to
         * using layer._url and layer._map.
         */
    Severity: Minor
    Found in src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.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

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

      getAndValidateTimeseries(metadata, area) {
        const validate = multiYearMeanSelected(this.props)
          ? validateAnnualCycleData
          : validateUnstructuredTimeseriesData;
        return getTimeseries(metadata, area)
    Severity: Major
    Found in src/components/graphs/TimeSeriesGraph/TimeSeriesGraph.js and 1 other location - About 1 hr to fix
    src/components/graphs/VariableResponseGraph/VariableResponseGraph.js on lines 62..69

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

    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

      it("converts timestamps into monthly values", function () {
        expect(
          util.timestampToTimeOfYear("1977-07-15T00:00:00Z", "monthly", false),
        ).toBe("July");
        expect(
    Severity: Major
    Found in src/core/__tests__/util-test.js and 1 other location - About 1 hr to fix
    src/core/__tests__/util-test.js on lines 424..431

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

    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

              <Col lg={6} md={6} sm={6}>
                <ExportButtons
                  onExportXlsx={this.handleExportXlsx}
                  onExportCsv={this.handleExportCsv}
                />
    Severity: Major
    Found in src/components/graphs/TimeSeriesGraph/TimeSeriesGraph.js and 1 other location - About 1 hr to fix
    src/components/graphs/AnnualCycleGraph/AnnualCycleGraph.js on lines 239..244

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

    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

      it("converts timestamps into annual values", function () {
        expect(
          util.timestampToTimeOfYear("1977-07-15T00:00:00Z", "yearly", true),
        ).toBe("Annual 1977");
        expect(
    Severity: Major
    Found in src/core/__tests__/util-test.js and 1 other location - About 1 hr to fix
    src/core/__tests__/util-test.js on lines 402..409

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

    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

      getAndValidateTimeseries(metadata, area) {
        const validate = multiYearMeanSelected(this.props)
          ? validateAnnualCycleData
          : validateUnstructuredTimeseriesData;
        return getTimeseries(metadata, area)
    src/components/graphs/TimeSeriesGraph/TimeSeriesGraph.js on lines 62..69

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

    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

              <Col lg={6} md={6} sm={6}>
                <ExportButtons
                  onExportXlsx={this.handleExportXlsx}
                  onExportCsv={this.handleExportCsv}
                />
    Severity: Major
    Found in src/components/graphs/AnnualCycleGraph/AnnualCycleGraph.js and 1 other location - About 1 hr to fix
    src/components/graphs/TimeSeriesGraph/TimeSeriesGraph.js on lines 129..134

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

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

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

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

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

        Function loadMap has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          loadMap(props, dataSpec, newVariable = false) {
            // Update state with all the information needed to display
            // maps for the specified dataspec.
            // A 'dataSpec' represents a combination of a specific variable,
            // emissions scenario, model, period, and run. The variable, emissions,

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

            render() {
              const faqs = T.get(this.context, "help.faq.items");
          
              if (!_.isArray(faqs)) {
                return null;
          Severity: Minor
          Found in src/components/guidance-content/help/FAQ.js - About 1 hr to fix

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

              function getMetadata(timeOfYear) {
                // get a list of all available percentiles
                function parsePercentile(metad) {
                  const clim_stat = metad["climatological_statistic"];
                  if (_.startsWith(clim_stat, "percentile")) {
            Severity: Minor
            Found in src/components/graphs/PercentileLongTermAveragesGraph.js - About 1 hr to fix

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

              export const HalfWidthCol = ({ children, ...rest }) => (
                <Col lg={6} md={6} sm={12} {...rest}>
                  {children}
                </Col>
              );
              Severity: Major
              Found in src/components/layout/rb-derived-components.js and 3 other locations - About 1 hr to fix
              src/components/layout/rb-derived-components.js on lines 4..8
              src/components/layout/rb-derived-components.js on lines 16..20
              src/components/layout/rb-derived-components.js on lines 22..26

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

              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

                shouldComponentUpdate(nextProps, nextState) {
                  const propChange = !_.isEqual(nextProps, this.props);
                  const stateChange = !_.isEqual(nextState, this.state);
                  const b = propChange || stateChange;
                  return b;
              Severity: Major
              Found in src/components/DataMap/DataLayer.js and 1 other location - About 1 hr to fix
              src/components/DataMap/DataMap.js on lines 321..326

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

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

              export const FullWidthCol = ({ children, ...rest }) => (
                <Col lg={12} md={12} sm={12} {...rest}>
                  {children}
                </Col>
              );
              Severity: Major
              Found in src/components/layout/rb-derived-components.js and 3 other locations - About 1 hr to fix
              src/components/layout/rb-derived-components.js on lines 10..14
              src/components/layout/rb-derived-components.js on lines 16..20
              src/components/layout/rb-derived-components.js on lines 22..26

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

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

              export const ThirdWidthCol = ({ children, ...rest }) => (
                <Col lg={4} md={12} sm={12} {...rest}>
                  {children}
                </Col>
              );
              Severity: Major
              Found in src/components/layout/rb-derived-components.js and 3 other locations - About 1 hr to fix
              src/components/layout/rb-derived-components.js on lines 4..8
              src/components/layout/rb-derived-components.js on lines 10..14
              src/components/layout/rb-derived-components.js on lines 22..26

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

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

              export const QuarterWidthCol = ({ children, ...rest }) => (
                <Col lg={3} md={12} sm={12} {...rest}>
                  {children}
                </Col>
              );
              Severity: Major
              Found in src/components/layout/rb-derived-components.js and 3 other locations - About 1 hr to fix
              src/components/layout/rb-derived-components.js on lines 4..8
              src/components/layout/rb-derived-components.js on lines 10..14
              src/components/layout/rb-derived-components.js on lines 16..20

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

              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

                shouldComponentUpdate(nextProps, nextState) {
                  const propChange = !_.isEqual(nextProps, this.props);
                  const stateChange = !_.isEqual(nextState, this.state);
                  const b = propChange || stateChange;
                  return b;
              Severity: Major
              Found in src/components/DataMap/DataMap.js and 1 other location - About 1 hr to fix
              src/components/DataMap/DataLayer.js on lines 21..26

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

              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