mangroveorg/datawinners

View on GitHub
datawinners/media/javascript/ol3-layerswitcher.js

Summary

Maintainability
F
1 wk
Test Coverage

Function LayerSwitcher has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ol.control.LayerSwitcher = function(opt_options) {

    var options = opt_options || {};

    var tipLabel = options.tipLabel ?
Severity: Minor
Found in datawinners/media/javascript/ol3-layerswitcher.js - About 1 hr to fix

    Function renderLayer_ has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ol.control.LayerSwitcher.prototype.renderLayer_ = function(lyr, idx) {
    
        var this_ = this;
    
        var li = document.createElement('li');
    Severity: Minor
    Found in datawinners/media/javascript/ol3-layerswitcher.js - About 1 hr to fix

      Function LayerSwitcher has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      ol.control.LayerSwitcher = function(opt_options) {
      
          var options = opt_options || {};
      
          var tipLabel = options.tipLabel ?
      Severity: Minor
      Found in datawinners/media/javascript/ol3-layerswitcher.js - About 55 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

      ol.control.LayerSwitcher.prototype.renderLayer_ = function(lyr, idx) {
      
          var this_ = this;
      
          var li = document.createElement('li');
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 2 days to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 161..206

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

      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

      ol.control.LayerSwitcher.prototype.setMap = function(map) {
          // Clean up listeners associated with the previous map
          for (var i = 0, key; i < this.mapListeners.length; i++) {
              this.getMap().unByKey(this.mapListeners[i]);
          }
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 1 day to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 104..119

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

      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

      ol.control.LayerSwitcher.prototype.renderLayers_ = function(lyr, elm) {
          var lyrs = lyr.getLayers().getArray().slice().reverse();
          for (var i = 0, l; i < lyrs.length; i++) {
              l = lyrs[i];
              if (l.get('title') && l.get('displayInLayerSwitcher')!=false) {
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 6 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 214..222

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

      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

      ol.control.LayerSwitcher.prototype.setVisible_ = function(lyr, visible) {
          var map = this.getMap();
          lyr.setVisible(visible);
          if (visible && lyr.get('type') === 'base') {
              // Hide all other base layers regardless of grouping
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 5 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 142..153

      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

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

      ol.control.LayerSwitcher.enableTouchScroll_ = function(elm) {
         if(ol.control.LayerSwitcher.isTouchDevice_()){
             var scrollStartPos = 0;
             elm.addEventListener("touchstart", function(event) {
                 scrollStartPos = this.scrollTop + event.touches[0].pageY;
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 2 other locations - About 5 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 258..268
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-popup.js on lines 153..163

      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

      ol.control.LayerSwitcher.prototype.renderPanel = function() {
      
          this.ensureTopVisibleBaseLayerShown_();
      
          while(this.panel.firstChild) {
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 4 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 86..98

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

      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

      ol.control.LayerSwitcher.prototype.ensureTopVisibleBaseLayerShown_ = function() {
          var lastVisibleBaseLyr;
          ol.control.LayerSwitcher.forEachRecursive(this.getMap(), function(l, idx, a) {
              if (l.get('type') === 'base' && l.getVisible()) {
                  lastVisibleBaseLyr = l;
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 4 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 125..133

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

      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

      ol.control.LayerSwitcher.uuid = function() {
          return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
              var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
              return v.toString(16);
          });
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 3 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 246..251

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

      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

      ol.control.LayerSwitcher.forEachRecursive = function(lyr, fn) {
          lyr.getLayers().forEach(function(lyr, idx, a) {
              fn(lyr, idx, a);
              if (lyr.getLayers) {
                  ol.control.LayerSwitcher.forEachRecursive(lyr, fn);
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 3 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 231..238

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

      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

      ol.control.LayerSwitcher.prototype.showPanel = function() {
          if (this.element.className != this.shownClassName) {
              this.element.className = this.shownClassName;
              this.renderPanel();
          }
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 2 hrs to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 67..72

      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

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

      ol.control.LayerSwitcher.prototype.hidePanel = function() {
          if (this.element.className != this.hiddenClassName) {
              this.element.className = this.hiddenClassName;
          }
      };
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 1 hr to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 77..81

      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

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

      ol.control.LayerSwitcher.isTouchDevice_ = function() {
          try {
              document.createEvent("TouchEvent");
              return true;
          } catch(e) {
      Severity: Major
      Found in datawinners/media/javascript/ol3-layerswitcher.js and 1 other location - About 1 hr to fix
      datawinners/media/javascript/OpenLayers-v3.17.1-dist/ol3-layerswitcher.js on lines 275..282

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

      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