pacificclimate/climate-explorer-frontend

View on GitHub

Showing 358 of 358 total issues

Function assignColoursByGroup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function assignColoursByGroup(
  graph,
  segmentor,
  colourList = category10Colours,
) {
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

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

    const metadatas = uniqueContextModelIds
      .map((model_id) => ({ ...baseMetadata, model_id }))
      .filter(
        (metadata) =>
          // Note: length > 0 guaranteed for item containing props.model_id
Severity: Major
Found in src/components/graphs/SingleTimeSliceGraph.js and 1 other location - About 1 hr to fix
src/components/graphs/SingleContextGraph.js on lines 42..51

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

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

var generateDataCellsFromC3Graph = function (
  graph,
  seriesLabel = "Time Series",
  variable = "",
) {
Severity: Minor
Found in src/core/export.js - About 1 hr to fix

    Function onAdd has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      onAdd: function () {
        // Container element
        this.container = L.DomUtil.create("div", "leaflet-control");
    
        Object.assign(this.container.style, {
    Severity: Minor
    Found in src/core/leaflet-ncwms-colorbar.js - About 1 hr to fix

      Function refreshValues has 42 lines of code (exceeds 25 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/core/leaflet-ncwms-colorbar.js - About 1 hr to fix

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

          loadMap(props, dataSpec, newVariable = false, newComparand = false) {
            // update state with all the information needed to display
            // maps for specific dataspecs.
            // A 'dataspec' is a variable + emissions + model + period + run combination.
            // Timestamps for an dataspec may be spread across up to three files

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

                  raster={{
                    times,
                    timeIdx: Object.keys(times)[0],
                    palette: "seq-Blues",
                    range: { min: -23 },
          Severity: Major
          Found in src/components/MapSettings/__tests__/MapSettings-smoke.js and 1 other location - About 1 hr to fix
          src/components/MapSettings/__tests__/MapSettingsDialog-smoke.js on lines 19..28

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

          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

                <Row>
                  <HalfWidthCol>
                    <ListGroup>{firstItems}</ListGroup>
                  </HalfWidthCol>
                  <HalfWidthCol>
          Severity: Major
          Found in src/components/guidance-content/help/Glossary.js and 1 other location - About 1 hr to fix
          src/components/guidance-content/help/FAQ.js on lines 42..50

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

          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

                  raster={{
                    times,
                    timeIdx: Object.keys(times)[0],
                    palette: "seq-Blues",
                    range: { min: -23 },
          src/components/MapSettings/__tests__/MapSettings-smoke.js on lines 16..25

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

          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

                  <Row>
                    <HalfWidthCol>
                      <Accordion>{firstItems}</Accordion>
                    </HalfWidthCol>
          
          
          Severity: Major
          Found in src/components/guidance-content/help/FAQ.js and 1 other location - About 1 hr to fix
          src/components/guidance-content/help/Glossary.js on lines 37..44

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

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

          var allDefinedObject = function (obj) {
            for (let att in obj) {
              if (typeof obj[att] == "undefined") {
                return false;
              } else if (typeof obj[att] == "object") {
          Severity: Minor
          Found in src/core/__test_data__/test-validators.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 getAllTimestamps has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function getAllTimestamps(data) {
            let allTimes = [];
          
            const addSeries = function (seriesData) {
              for (let timestamp in seriesData) {
          Severity: Minor
          Found in src/core/chart-generators.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 render has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            render() {
              return (
                <Panel>
                  <Panel.Heading>
                    <Panel.Title>
          Severity: Minor
          Found in src/components/StatisticalSummaryTable/StatisticalSummaryTable.js - About 1 hr to fix

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

              setTimeseriesGraphNoDataMessage: function (message) {
                this.setState({
                  timeseriesData: {
                    data: { columns: [], empty: { label: { text: message } } },
                    axis: {},
            src/components/data-controllers/MotiDataController/MotiDataController.js on lines 173..180

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

            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

            const tasmaxData = {
              r1i1p1: {
                data: {
                  "1997-01-15T00:00:00Z": -19.534196834187902,
                  "2055-01-15T00:00:00Z": -17.825752320828578,
            Severity: Major
            Found in src/core/__test_data__/sample-API-results.js and 1 other location - About 1 hr to fix
            src/core/__test_data__/sample-API-results.js on lines 154..166

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

            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

            const tasminData = {
              r1i1p1: {
                data: {
                  "1997-01-15T00:00:00Z": -28.265036079409857,
                  "2055-01-15T00:00:00Z": -24.776227407561837,
            Severity: Major
            Found in src/core/__test_data__/sample-API-results.js and 1 other location - About 1 hr to fix
            src/core/__test_data__/sample-API-results.js on lines 140..152

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

            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

              setAnnualCycleGraphNoDataMessage: function (message) {
                this.setState({
                  annualCycleData: {
                    data: { columns: [], empty: { label: { text: message } } },
                    axis: {},
            src/components/data-controllers/MotiDataController/MotiDataController.js on lines 191..198

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

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

            function makeTimeSliceGraph(timestamp, graph) {
              let slicedData = [];
              let timestamps = [];
              let sliceIndex = -1;
            
            
            Severity: Minor
            Found in src/core/chart-transformers.js - About 1 hr to fix

              Function matchYAxisRange has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function matchYAxisRange(graph) {
                const y = graph.axis.y;
                const y2 = graph.axis.y2;
              
                if (!(y && y2)) {
              Severity: Minor
              Found in src/core/chart-formatters.js - About 1 hr to fix

                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);
                Severity: Major
                Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 1 hr to fix
                src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 80..83

                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

                Severity
                Category
                Status
                Source
                Language