sentilo/sentilo

View on GitHub
sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js

Summary

Maintainability
F
4 days
Test Coverage

File markerclusterer.js has 711 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @name MarkerClustererPlus for Google Maps V3
 * @version 2.1.1 [November 4, 2013]
 * @author Gary Little
 * @fileoverview
Severity: Major
Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 1 day to fix

    Function createClusters_ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    MarkerClusterer.prototype.createClusters_ = function (iFirst) {
      var i, marker;
      var mapBounds;
      var cMarkerClusterer = this;
      if (!this.ready_) {
    Severity: Minor
    Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.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 addMarker has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    Cluster.prototype.addMarker = function (marker) {
      var i;
      var mCount;
      var mz;
    
    
    Severity: Minor
    Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.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 onAdd has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ClusterIcon.prototype.onAdd = function () {
      var cClusterIcon = this;
      var cMouseDownInCluster;
      var cDraggingMapByCluster;
    
    
    Severity: Minor
    Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 1 hr to fix

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

      function MarkerClusterer(map, opt_markers, opt_options) {
        // MarkerClusterer implements google.maps.OverlayView interface. We use the
        // extend function to extend MarkerClusterer with google.maps.OverlayView
        // because it might not always be available when the code is defined so we
        // look for it at the last possible moment. If it doesn't exist now then
      Severity: Minor
      Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 1 hr to fix

        Function addMarker has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Cluster.prototype.addMarker = function (marker) {
          var i;
          var mCount;
          var mz;
        
        
        Severity: Minor
        Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 1 hr to fix

          Function createClusters_ has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          MarkerClusterer.prototype.createClusters_ = function (iFirst) {
            var i, marker;
            var mapBounds;
            var cMarkerClusterer = this;
            if (!this.ready_) {
          Severity: Minor
          Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 1 hr to fix

            Function show has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ClusterIcon.prototype.show = function () {
              if (this.div_) {
                var img = "";
                // NOTE: values must be specified in px units
                var bp = this.backgroundPosition_.split(" ");
            Severity: Minor
            Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 1 hr to fix

              Function addToClosestCluster_ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              MarkerClusterer.prototype.addToClosestCluster_ = function (marker) {
                var i, d, cluster, center;
                var distance = 40000; // Some large number
                var clusterToAddTo = null;
                for (i = 0; i < this.clusters_.length; i++) {
              Severity: Minor
              Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 45 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

              Function removeMarker_ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              MarkerClusterer.prototype.removeMarker_ = function (marker) {
                var i;
                var index = -1;
                if (this.markers_.indexOf) {
                  index = this.markers_.indexOf(marker);
              Severity: Minor
              Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 45 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

              Function isMarkerAlreadyAdded_ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              Cluster.prototype.isMarkerAlreadyAdded_ = function (marker) {
                var i;
                if (this.markers_.indexOf) {
                  return this.markers_.indexOf(marker) !== -1;
                } else {
              Severity: Minor
              Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 35 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

              Function show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              ClusterIcon.prototype.show = function () {
                if (this.div_) {
                  var img = "";
                  // NOTE: values must be specified in px units
                  var bp = this.backgroundPosition_.split(" ");
              Severity: Minor
              Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js - About 35 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

              Function MarkerClusterer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function MarkerClusterer(map, opt_markers, opt_options) {
                // MarkerClusterer implements google.maps.OverlayView interface. We use the
                // extend function to extend MarkerClusterer with google.maps.OverlayView
                // because it might not always be available when the code is defined so we
                // look for it at the last possible moment. If it doesn't exist now then
              Severity: Minor
              Found in sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.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

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

                google.maps.event.addDomListener(this.div_, "mouseover", function () {
                  var mc = cClusterIcon.cluster_.getMarkerClusterer();
                  /**
                   * This event is fired when the mouse moves over a cluster marker.
                   * @name MarkerClusterer#mouseover
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 189..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 77.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                google.maps.event.addDomListener(this.div_, "mouseout", function () {
                  var mc = cClusterIcon.cluster_.getMarkerClusterer();
                  /**
                   * This event is fired when the mouse moves out of a cluster marker.
                   * @name MarkerClusterer#mouseout
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 178..187

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 77.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                for (i = 0; i < this.clusters_.length; i++) {
                  this.clusters_[i].remove();
                }
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 770..772

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

              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

                for (i = 0; i < this.clusters_.length; i++) {
                  this.clusters_[i].remove();
                }
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 1387..1389

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

              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 lat = (this.center_.lat() * (l - 1) + marker.getPosition().lat()) / l;
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 478..478

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

              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 lng = (this.center_.lng() * (l - 1) + marker.getPosition().lng()) / l;
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 477..477

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

              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

                for (i = 0; i < markers.length; i++) {
                  bounds.extend(markers[i].getPosition());
                }
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 820..822

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

              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

                for (i = 0; i < markers.length; i++) {
                  bounds.extend(markers[i].getPosition());
                }
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 436..438

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

              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 tr = new google.maps.LatLng(bounds.getNorthEast().lat(),
                    bounds.getNorthEast().lng());
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 1345..1346

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

              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 bl = new google.maps.LatLng(bounds.getSouthWest().lat(),
                    bounds.getSouthWest().lng());
              sentilo-catalog-web/src/main/webapp/static/js/markerclusterer.js on lines 1343..1344

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

              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