pacificclimate/climate-explorer-frontend

View on GitHub

Showing 358 of 358 total issues

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

  if (metadata.comparand_id && metadata.comparand_id !== metadata.variable_id) {
    header.push("Comparand ID");
    header.push("Comparand Name");
    values.push(metadata.comparand_id);
    values.push(metadata.comparandMeta[0].variable_name);
Severity: Major
Found in src/core/export.js and 1 other location - About 2 hrs to fix
src/core/export.js on lines 210..215

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

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

function assignDataToYAxis(graph, seriesMetadata, groupByUnits = false) {
  // get sorting algorithm, if the chart already has one.
  const sortingParams = {
    y: axisSortingParams(graph, "y"),
    y2: axisSortingParams(graph, "y2"),
Severity: Major
Found in src/core/chart-generators.js - About 2 hrs to fix

    Function dataToLongTermAverageGraph has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function dataToLongTermAverageGraph(data, contexts = []) {
      // 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 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

    Function dataToLongTermAverageGraph has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

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

          if (hasValidData("variable", nextProps)) {
            const defaultDataset = nextProps.meta[0];
            const defaultDataSpec = _.pick(
              defaultDataset,
              "start_date",
      src/components/map-controllers/SingleMapController/SingleMapController.js on lines 183..209

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

      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

          if (hasValidData("variable", nextProps)) {
            const defaultDataset = nextProps.meta[0];
            const defaultDataSpec = _.pick(
              defaultDataset,
              "start_date",
      src/components/map-controllers/PrecipMapController/PrecipMapController.js on lines 221..249

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

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

        getData: function (props) {
          if (this.multiYearMeanSelected(props)) {
            //load Annual Cycle graph
            this.setAnnualCycleGraphNoDataMessage("Loading Data");
      
      

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

        export const downloadGraphDataLabel = (
          <LabelWithInfo label={exportDataLabel}>
            <p>Click a button to download the selected data to your computer.</p>
            <p>
              The data downloaded is that shown on the graph. For details on the layout
        Severity: Major
        Found in src/components/guidance-content/info/InformationItems.js and 1 other location - About 2 hrs to fix
        src/components/guidance-content/info/InformationItems.js on lines 789..801

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

        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

        export const exportStatsTableDataLabel = (
          <LabelWithInfo label={exportDataLabel}>
            <p>
              Click a button to export the contents of the statistical summary table.
            </p>
        Severity: Major
        Found in src/components/guidance-content/info/InformationItems.js and 1 other location - About 2 hrs to fix
        src/components/guidance-content/info/InformationItems.js on lines 537..547

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

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

          File DualMapController.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*************************************************************************
           * DualMapController - displays two variables on the map at once
           *
           * This controller coordinates a map displaying two layers at once:
           *   * A raster layer with colour shading reflecting values
          Severity: Minor
          Found in src/components/map-controllers/DualMapController/DualMapController.js - About 2 hrs to fix

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

            it("renders without crashing", () => {
              const div = document.createElement("div");
              div.style.height = 100;
              ReactDOM.render(
                <Map>
            src/components/NcWMSColorbarControl/__tests__/smoke.js on lines 6..15
            src/components/StaticControl/__tests__/smoke.js on lines 6..15

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

            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

            it("renders without crashing", () => {
              const div = document.createElement("div");
              div.style.height = 100;
              ReactDOM.render(
                <Map>
            Severity: Major
            Found in src/components/StaticControl/__tests__/smoke.js and 2 other locations - About 2 hrs to fix
            src/components/NcWMSAutosetColorscaleControl/__tests__/smoke.js on lines 6..17
            src/components/NcWMSColorbarControl/__tests__/smoke.js on lines 6..15

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

            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

            it("renders without crashing", () => {
              const div = document.createElement("div");
              div.style.height = 100;
              ReactDOM.render(
                <Map>
            Severity: Major
            Found in src/components/NcWMSColorbarControl/__tests__/smoke.js and 2 other locations - About 2 hrs to fix
            src/components/NcWMSAutosetColorscaleControl/__tests__/smoke.js on lines 6..17
            src/components/StaticControl/__tests__/smoke.js on lines 6..15

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

            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

            export const singleAnnualCycleTabLabel = (
              <LabelWithInfo label="Annual Cycle">
                <p>
                  Annual cycle graph showing the annual, seasonal, and monthly mean values
                  of the selected variable.
            Severity: Major
            Found in src/components/guidance-content/info/InformationItems.js and 1 other location - About 2 hrs to fix
            src/components/guidance-content/info/InformationItems.js on lines 660..667

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

            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

            export const percentileLtaTabLabel = (
              <LabelWithInfo label="Design Values">
                <p>Design value graphs with percentile range for the selected variable.</p>
                <p>{designValueGraphDefn}</p>
                <p>{pointAreaDefn}</p>
            Severity: Major
            Found in src/components/guidance-content/info/InformationItems.js and 1 other location - About 2 hrs to fix
            src/components/guidance-content/info/InformationItems.js on lines 609..619

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

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

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

              Function AnomalyAnnualCycleGraph has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function AnomalyAnnualCycleGraph(props) {
                function getDateRangeMetadatas(start = undefined, end = undefined) {
                  // returns metadata for all datasets whose model, experiment, and variable
                  // match the values specified in props, and whose start year is greater
                  //than start, and whose end year is less than end.
              Severity: Major
              Found in src/components/graphs/AnomalyAnnualCycleGraph.js - About 2 hrs to fix

                File chart-transformers.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /************************************************************************
                 * chart-transformers.js - functions that accept a C3 chart specification
                 *   for a timeseries chart and alter the data to produce a different
                 *   type of chart.
                 *
                Severity: Minor
                Found in src/core/chart-transformers.js - About 2 hrs to fix

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

                                  <MEVSummary
                                    model_id={this.props.model_id}
                                    experiment={this.props.experiment}
                                    variable_id={this.props.variable_id}
                                    comparand_id={this.props.comparand_id}
                  src/components/MapSettings/DataDisplayControls.js on lines 33..39

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

                  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