pacificclimate/climate-explorer-frontend

View on GitHub
src/core/leaflet-ncwms-colorbar.js

Summary

Maintainability
F
4 days
Test Coverage

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 refreshValues has a Cognitive Complexity of 6 (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/core/leaflet-ncwms-colorbar.js - About 25 mins 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

        redraw: function () {
          this.container.style.backgroundImage = 'url("' + this.graphicUrl() + '")';
          this.maxContainer.innerHTML = round(this.max, this.getDecimalPrecision());
          this.midContainer.innerHTML = round(
            this.getMidpoint(this.min, this.max, this.layer.wmsParams.logscale),
      Severity: Major
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 6 hrs to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 237..245

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

      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

          Object.assign(this.container.style, {
            position: "relative",
            width: this.options.width + "px",
            height: this.options.height + "px",
            borderWidth: this.options.borderWidth + "px",
      Severity: Major
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 5 hrs to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 47..59

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

      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

              return axios(this.layer._url, {
                params: {
                  request: "GetMetadata",
                  item: "minmax",
                  layers: escape(this.layer.wmsParams.layers),
      Severity: Major
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 5 hrs to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 158..173

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

      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

        getMidpoint: function (mn, mx, logscale) {
          var mid;
      
          if (logscale === true || logscale === "true") {
            var logMin = mn <= 0 ? 1 : mn;
      Severity: Major
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 4 hrs to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 194..204

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

      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

        graphicUrl: function () {
          var palette = this.layer.wmsParams.styles.split("/")[1];
          return (
            this.layer._url +
            "?REQUEST=GetLegendGraphic" +
      Severity: Major
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 3 hrs to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 206..220

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

      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 (this.layer.wmsParams.colorscalerange) {
            // Use colorscalerange if defined on the layer
            this.min = +this.layer.wmsParams.colorscalerange.split(",")[0];
            this.max = +this.layer.wmsParams.colorscalerange.split(",")[1];
            this.redraw();
      Severity: Major
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 2 hrs to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 117..191

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

      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

            var getLayerInfo = axios(this.layer._url, {
              dataType: "json",
              params: {
                request: "GetMetadata",
                item: "layerDetails",
      Severity: Major
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 2 hrs to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 129..137

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

      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

            getLayerInfo.then(getMinMax).then((response) => {
              this.min = response.data.min;
              this.max = response.data.max;
              this.redraw();
            });
      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 176..182

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

      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

          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

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

        options: {
          position: "bottomright",
          decimalPlaces: 2,
          width: 20,
          height: 300,
      Severity: Minor
      Found in src/core/leaflet-ncwms-colorbar.js and 1 other location - About 50 mins to fix
      src/components/NcWMSColorbarControl/LeafletNcWMSColorbarControl.js on lines 11..21

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

      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

      There are no issues that match your filters.

      Category
      Status