pacificclimate/climate-explorer-frontend

View on GitHub

Showing 358 of 358 total issues

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

  componentDidUpdate(prevProps, prevState) {
    if (
      prevProps.meta !== this.props.meta ||
      prevProps.area !== this.props.area ||
      prevState.timeOfYear !== this.state.timeOfYear
src/components/graphs/TimeSeriesGraph/TimeSeriesGraph.js on lines 101..109

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

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

describe("DataTable", function () {
  it("renders", function () {
    var table = TestUtils.renderIntoDocument(<DataTable data={[]} />);
    expect(TestUtils.isCompositeComponent(table)).toBeTruthy();
  });
Severity: Major
Found in src/components/DataTable/__tests__/DataTable-test.js and 1 other location - About 2 hrs to fix
src/components/AttributeValueTable/__tests__/AttributeValueTable-test.js on lines 9..14

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

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

      myTimeseriesPromise
        .then((response) => {
          this.setState({
            timeseriesData: timeseriesToTimeseriesGraph(
              props.meta,
src/components/data-controllers/MotiDataController/MotiDataController.js on lines 112..123

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

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

describe("AttributeValueTable", function () {
  it("renders", function () {
    var table = TestUtils.renderIntoDocument(<AttributeValueTable data={[]} />);
    expect(TestUtils.isCompositeComponent(table)).toBeTruthy();
  });
src/components/DataTable/__tests__/DataTable-test.js on lines 8..13

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

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

  componentDidUpdate(prevProps, prevState) {
    if (
      prevProps.meta !== this.props.meta ||
      prevProps.area !== this.props.area ||
      prevState.timeOfYear !== this.state.timeOfYear
Severity: Major
Found in src/components/graphs/TimeSeriesGraph/TimeSeriesGraph.js and 1 other location - About 2 hrs to fix
src/components/graphs/VariableResponseGraph/VariableResponseGraph.js on lines 112..120

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

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

var generateDataCellsFromC3Graph = function (
  graph,
  seriesLabel = "Time Series",
  variable = "",
) {
Severity: Minor
Found in src/core/export.js - About 2 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

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

  it("rejects data sets without units", function () {
    var noUnits = _.omit(mockAPI.monthlyTasmaxTimeseries, "units");
    const func = () => {
      util.validateAnnualCycleData({ data: noUnits });
    };
Severity: Major
Found in src/core/__tests__/util-test.js and 1 other location - About 2 hrs to fix
src/core/__tests__/util-test.js on lines 259..265

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

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("rejects data sets without units", function () {
    var noUnits = _.omit(mockAPI.monthlyTasmaxTimeseries, "units");
    const func = () => {
      util.validateUnstructuredTimeseriesData({ data: noUnits });
    };
Severity: Major
Found in src/core/__tests__/util-test.js and 1 other location - About 2 hrs to fix
src/core/__tests__/util-test.js on lines 199..205

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

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

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

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

    File DataMap.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // This component provides data display layers (DataLayer) for up to two
    // variables, plus a geometry layer, geometry creation and editing tools,
    // and geometry import/export tools, all rendered within the base map
    // (CanadaBaseMap).
    //
    Severity: Minor
    Found in src/components/DataMap/DataMap.js - About 2 hrs to fix

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

        shouldComponentUpdate(nextProps, nextState) {
          // This guards against re-rendering before we have required data
          // TODO: Make more efficient?
          // Currently doing deep comparison on big objects (meta).
          // Deep comparison matters on rasterRange, but not on
      src/components/map-controllers/DualMapController/DualMapController.js on lines 288..299
      src/components/map-controllers/PrecipMapController/PrecipMapController.js on lines 252..263

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

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

        shouldComponentUpdate(nextProps, nextState) {
          // This guards against re-rendering before we have required data
          // TODO: Make more efficient?
          // Currently doing deep comparison on big objects (meta, comparandMeta).
          // Deep comparison matters on rasterRange, annotatedRange, but not on
      src/components/map-controllers/DualMapController/DualMapController.js on lines 288..299
      src/components/map-controllers/SingleMapController/SingleMapController.js on lines 212..223

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

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

        shouldComponentUpdate(nextProps, nextState) {
          // This guards against re-rendering before we have required data
          // TODO: Make more efficient?
          // Currently doing deep comparison on big objects (meta, comparandMeta).
          // Deep comparison matters on rasterRange, isolineRange, but not on
      src/components/map-controllers/PrecipMapController/PrecipMapController.js on lines 252..263
      src/components/map-controllers/SingleMapController/SingleMapController.js on lines 212..223

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

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

      export default function SingleAnnualCycleGraph(props) {
        function getMetadata(dataSpec) {
          // Find and return metadata matching the parameters in the dataSpec:
          // model_id, experiment, variable_id (supplied by parent)
          // start_date, end_date, ensemble_name (chosen by this component)
      Severity: Minor
      Found in src/components/graphs/SingleAnnualCycleGraph.js - About 2 hrs to fix

        Function DualTimeSeriesGraph has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Function compAcontrolsB has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function compAcontrolsB(A, B, Wrapper = "div", label = "") {
            return class extends React.Component {
              static propTypes = {
                controls: PropTypes.array,
              };
          Severity: Minor
          Found in src/HOCs/compAcontrolsB.js - About 1 hr to fix

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

            it("renders without crashing", () => {
              const div = document.createElement("div");
              ReactDOM.render(
                <FilteredDatasetsSummary
                  model_id={"GFDL-ESM2G"}
            src/components/StatisticalSummaryTable/__tests__/smoke.js on lines 8..19

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

            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("renders without crashing", () => {
              const div = document.createElement("div");
              ReactDOM.render(
                <StatisticalSummaryTable
                  model_id={"GFDL-ESM2G"}
            Severity: Major
            Found in src/components/StatisticalSummaryTable/__tests__/smoke.js and 1 other location - About 1 hr to fix
            src/components/data-presentation/FilteredDatasetsSummary/__tests__/smoke.js on lines 6..17

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

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

            function timeseriesToAnnualCycleGraph(metadata, ...data) {
              // blank graph data object to be populated - holds data values
              // and individual-timeseries-level display options.
              let c3Data = {
                columns: [],
            Severity: Minor
            Found in src/core/chart-generators.js - About 1 hr to fix

              Function shortestUniqueTimeseriesNamingFunction has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function shortestUniqueTimeseriesNamingFunction(metadata, data) {
                if (metadata.length === 0) {
                  throw new Error("No data to show");
                }
              
              
              Severity: Minor
              Found in src/core/chart-generators.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language