SpeciesFileGroup/taxonworks

View on GitHub
app/assets/javascripts/vendor/lib/google/maps/draw.js

Summary

Maintainability
D
3 days
Test Coverage

Function initializeGoogleMap has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    initializeGoogleMap: function (map_canvas, fcdata, map_center) {

      // does this need to be set?  would it alter fcdata if not set?
      var mapData = fcdata;
      //
Severity: Major
Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - About 3 hrs to fix

    Function initializeDrawingManager has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        initializeDrawingManager: function (map, mapDrawingModes) {
          var drawingMode = undefined;      // "active: circle, polygon, circle" results in hand, polygon, circle(selected)
          var drawingModes = [];            // "polygon, circle" results in hand(active), polygon, circle in draw mode menu
          var i;                  // loop counter
          var j = 0;              // offset for start of i-loop when ACTIVE:mode has explicit position
    Severity: Major
    Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - About 3 hrs to fix

      File draw.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
       * extended library to construct drawable Google map instances
       */
      var TW = TW || {};                      // TW "namespacing" object
      TW.vendor = TW.vendor || {};            // mimic directory structure in app/assets/javascripts
      Severity: Minor
      Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - About 2 hrs to fix

        Function initializeDrawingManager has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            initializeDrawingManager: function (map, mapDrawingModes) {
              var drawingMode = undefined;      // "active: circle, polygon, circle" results in hand, polygon, circle(selected)
              var drawingModes = [];            // "polygon, circle" results in hand(active), polygon, circle in draw mode menu
              var i;                  // loop counter
              var j = 0;              // offset for start of i-loop when ACTIVE:mode has explicit position
        Severity: Minor
        Found in app/assets/javascripts/vendor/lib/google/maps/draw.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 buildFeatureCollectionFromShape has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            buildFeatureCollectionFromShape: function (shape, shape_type) {
        
              //  var featureCollection = [];
              var feature = [];
              var coordinates = [];
        Severity: Minor
        Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - About 1 hr to fix

          Function initializeGoogleMap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              initializeGoogleMap: function (map_canvas, fcdata, map_center) {
          
                // does this need to be set?  would it alter fcdata if not set?
                var mapData = fcdata;
                //
          Severity: Minor
          Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function singleDrawnFeatureToMapListeners has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              singleDrawnFeatureToMapListeners: function (this_map, map_item, feature_control) {
                google.maps.event.addListener(this_map[1], 'overlaycomplete', function (event) {
                    // Remove the last created shape if it exists.
                    if (map_item != null) {
                      if (map_item[0] != null) {
          Severity: Minor
          Found in app/assets/javascripts/vendor/lib/google/maps/draw.js - About 1 hr to fix

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

                singleDrawnFeatureToMapListeners: function (this_map, map_item, feature_control) {
                  google.maps.event.addListener(this_map[1], 'overlaycomplete', function (event) {
                      // Remove the last created shape if it exists.
                      if (map_item != null) {
                        if (map_item[0] != null) {
            Severity: Minor
            Found in app/assets/javascripts/vendor/lib/google/maps/draw.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

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

                buildFeatureCollectionFromShape: function (shape, shape_type) {
            
                  //  var featureCollection = [];
                  var feature = [];
                  var coordinates = [];
            Severity: Minor
            Found in app/assets/javascripts/vendor/lib/google/maps/draw.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

            TODO found
            Open

                  // TODO: what does this actually do, should it be calculateCenter()?  If it is

            TODO found
            Open

            // TODO: make more forgiving by allowing null fcdata or map_center_parts (stub blank legal values)

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

                        google.maps.event.addListener(map_item[0], 'radius_changed', function (event) {
                          var feature = TW.vendor.lib.google.maps.draw.buildFeatureCollectionFromShape(map_item[0], map_item[1]);
                          $(feature_control).val(JSON.stringify(feature[0]));
                        });
            Severity: Major
            Found in app/assets/javascripts/vendor/lib/google/maps/draw.js and 1 other location - About 3 hrs to fix
            app/assets/javascripts/vendor/lib/google/maps/draw.js on lines 155..158

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

            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.addListener(map_item[0], 'center_changed', function (event) {
                          var feature = TW.vendor.lib.google.maps.draw.buildFeatureCollectionFromShape(map_item[0], map_item[1]);
                          $(feature_control).val(JSON.stringify(feature[0]));
                        });
            Severity: Major
            Found in app/assets/javascripts/vendor/lib/google/maps/draw.js and 1 other location - About 3 hrs to fix
            app/assets/javascripts/vendor/lib/google/maps/draw.js on lines 151..154

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

            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

            TW.vendor.lib.google.maps.draw = TW.vendor.lib.google.maps.draw || {};
            Severity: Major
            Found in app/assets/javascripts/vendor/lib/google/maps/draw.js and 2 other locations - About 50 mins to fix
            app/assets/javascripts/views/tasks/collecting_events/parse/dates/index.js on lines 6..6
            app/assets/javascripts/views/tasks/collecting_events/parse/lat_long/index.js on lines 6..6

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

            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