nodetiles/nodetiles-core

View on GitHub
datasources/Shp.js

Summary

Maintainability
F
1 wk
Test Coverage

Function _shapeBounds has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  _shapeBounds: function(shape) {
    shape = shape.geometry || shape;
    var coordinates = shape.coordinates;

    if (shape.type === "Point") {
Severity: Minor
Found in datasources/Shp.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 _shapeBounds has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _shapeBounds: function(shape) {
    shape = shape.geometry || shape;
    var coordinates = shape.coordinates;

    if (shape.type === "Point") {
Severity: Minor
Found in datasources/Shp.js - About 2 hrs to fix

    Function _shapes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      _shapes: function(feature) {
        var shapes = [];
        if (feature.type === "FeatureCollection") {
          for (var i = feature.features.length - 1; i >= 0; i--) {
            shapes = shapes.concat(this._shapes(feature.features[i]));
    Severity: Minor
    Found in datasources/Shp.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 intersects has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    var intersects = function(a, b) {
      var xIntersects = (a.minX < b.maxX && a.minX > b.minX) ||
        (a.maxX < b.maxX && a.maxX > b.minX) ||
        (a.minX < b.minX && a.maxX > b.maxX);
    
    
    Severity: Minor
    Found in datasources/Shp.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 getShapes has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      getShapes: function(minX, minY, maxX, maxY, mapProjection, callback) {
    Severity: Minor
    Found in datasources/Shp.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                for (var k = coordinateSetSet.length - 1; k >= 0; k--) {
                  bounds.minX = Math.min(bounds.minX, coordinateSetSet[k][0]);
                  bounds.maxX = Math.max(bounds.maxX, coordinateSetSet[k][0]);
                  bounds.minY = Math.min(bounds.minY, coordinateSetSet[k][1]);
                  bounds.maxY = Math.max(bounds.maxY, coordinateSetSet[k][1]);
      Severity: Major
      Found in datasources/Shp.js - About 45 mins to fix

        Function _filterByExtent has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          _filterByExtent: function(dataset, minX, minY, maxX, maxY) {
        Severity: Minor
        Found in datasources/Shp.js - About 35 mins to fix

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

            getShapes: function(minX, minY, maxX, maxY, mapProjection, callback) {
              if (this._projectedData[mapProjection]){
                var data = this._filterByExtent(this._projectedData[mapProjection], minX, minY, maxX, maxY);
                callback(null, data);
              }
          Severity: Minor
          Found in datasources/Shp.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

            _shapeBounds: function(shape) {
              shape = shape.geometry || shape;
              var coordinates = shape.coordinates;
          
              if (shape.type === "Point") {
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 4 days to fix
          datasources/GeoJson.js on lines 139..194

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

          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

            _shapes: function(feature) {
              var shapes = [];
              if (feature.type === "FeatureCollection") {
                for (var i = feature.features.length - 1; i >= 0; i--) {
                  shapes = shapes.concat(this._shapes(feature.features[i]));
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 1 day to fix
          datasources/GeoJson.js on lines 196..221

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

          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 intersects = function(a, b) {
            var xIntersects = (a.minX < b.maxX && a.minX > b.minX) ||
              (a.maxX < b.maxX && a.maxX > b.minX) ||
              (a.minX < b.minX && a.maxX > b.maxX);
          
          
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 1 day to fix
          datasources/GeoJson.js on lines 226..236

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

          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

            _project: function(mapProjection) {
              var doBounds = !this._projectedData[mapProjection];
          
              if (this._projection !== mapProjection) {
                console.log("Projecting features...");
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 1 day to fix
          datasources/GeoJson.js on lines 94..113

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

          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

            getShapes: function(minX, minY, maxX, maxY, mapProjection, callback) {
              if (this._projectedData[mapProjection]){
                var data = this._filterByExtent(this._projectedData[mapProjection], minX, minY, maxX, maxY);
                callback(null, data);
              }
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 7 hrs to fix
          datasources/GeoJson.js on lines 30..48

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

          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

            _filterByExtent: function(dataset, minX, minY, maxX, maxY) {
              if (!FILTER_BY_EXTENTS) {
                return dataset;
              }
          
          
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 3 hrs to fix
          datasources/GeoJson.js on lines 121..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 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

            if (this.name.indexOf(".") !== -1) {
              this.name = this.name.slice(0, this.name.indexOf("."));
            }
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 1 hr to fix
          datasources/GeoJson.js on lines 11..13

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

          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

            _calculateBounds: function(dataset) {
              return this._shapes(dataset).forEach(function(shape) {
                shape.bounds = this._shapeBounds(shape);
              }, this);
            },
          Severity: Major
          Found in datasources/Shp.js and 1 other location - About 1 hr to fix
          datasources/GeoJson.js on lines 115..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 56.

          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

            this.name = options.name || options.path.slice(options.path.lastIndexOf("/") + 1);
          Severity: Minor
          Found in datasources/Shp.js and 1 other location - About 35 mins to fix
          datasources/GeoJson.js on lines 10..10

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

          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