nodetiles/nodetiles-core

View on GitHub

Showing 100 of 100 total issues

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

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

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

File cartoRenderer.js has 933 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var Canvas = require('canvas');
var carto = require("carto");
var UTFGrid = require('./utfgrid');
var fs = require('fs');
var path = require('path');
Severity: Major
Found in lib/cartoRenderer.js - About 2 days to fix

    Function LineString has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
    Open

      'LineString': function(text, l) {
        // we support line and point, point is default
        if (text.placement === "line") {
          this.textAlign = "left";
          
    Severity: Minor
    Found in lib/cartoRenderer.js - About 1 day 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

      _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

    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/GeoJson.js and 1 other location - About 1 day to fix
    datasources/Shp.js on lines 188..213

    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

    Function cartoImageRenderer has 253 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var cartoImageRenderer = function (ctx, scale, layers, styles, zoom, minX, maxX, minY) {
      // background first
      styles.forEach(function(style) {
        if (cartoSelectorIsMatch(style, null, null, zoom)) {
          style.rules.forEach(function(rule) {
    Severity: Major
    Found in lib/cartoRenderer.js - About 1 day to fix

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

        if (featureImage) {
          callback(undefined, canvas);
        }
        else {
          var pixels = ctx.getImageData(0, 0, gridSize, gridSize).data; // array of all pixels
      Severity: Major
      Found in lib/cartoRenderer.js and 1 other location - About 1 day to fix
      lib/renderer.js on lines 81..104

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

      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 (featureImage) {
          callback(undefined, canvas);
        }
        else {
          var pixels = ctx.getImageData(0, 0, gridSize, gridSize).data; // array of all pixels
      Severity: Major
      Found in lib/renderer.js and 1 other location - About 1 day to fix
      lib/cartoRenderer.js on lines 85..108

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

      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

      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/GeoJson.js and 1 other location - About 1 day to fix
      datasources/Shp.js on lines 218..228

      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/GeoJson.js and 1 other location - About 1 day to fix
      datasources/Shp.js on lines 86..105

      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

      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

      Function renderInstance has 192 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              var renderInstance = function(instanceName) {
                var instanceStyle = collapsedStyle[instanceName];
                
                ctx.save();
        
      Severity: Major
      Found in lib/cartoRenderer.js - About 7 hrs to fix

        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/GeoJson.js and 1 other location - About 7 hrs to fix
        datasources/Shp.js on lines 29..47

        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

          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

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

          'LineString': function(radius, l) {
            // put the point at the center
            var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
            l.forEach(function(point) {
              minX = Math.min(minX, point[0]);
        Severity: Major
        Found in lib/cartoRenderer.js and 1 other location - About 7 hrs to fix
        lib/cartoRenderer.js on lines 302..312

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

        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

          'LineString': function(image, l) {
            // put the point at the center
            var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
            l.forEach(function(point) {
              minX = Math.min(minX, point[0]);
        Severity: Major
        Found in lib/cartoRenderer.js and 1 other location - About 7 hrs to fix
        lib/cartoRenderer.js on lines 337..347

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

        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

        Function LineString has 150 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          'LineString': function(text, l) {
            // we support line and point, point is default
            if (text.placement === "line") {
              this.textAlign = "left";
              
        Severity: Major
        Found in lib/cartoRenderer.js - About 6 hrs to fix

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

              'LineString': function(l) {
                  var start = l[0];
                  if (transform) {
                    start = transform(start);
                  }
          Severity: Major
          Found in lib/cartoRenderer.js and 1 other location - About 4 hrs to fix
          lib/renderer.js on lines 133..145

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

          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

          Severity
          Category
          Status
          Source
          Language