publiclab/mapknitter

View on GitHub

Showing 127 of 127 total issues

Function synchronizeNewAddedImage has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  synchronizeNewAddedImage: function(warpable) {
    var wn = warpable.nodes;
    var bounds = [];

    // only already-placed images:
Severity: Major
Found in app/assets/javascripts/mapknitter/Map.js - About 2 hrs to fix

    Method collect_ways has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.collect_ways(features)
        # collected_ways variable unused review this function
        collected_ways = []
        nodes = {}
        features['osm']['node'].each do |node|
    Severity: Minor
    Found in lib/cartagen.rb - 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

    Map has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    MapKnitter.Map = MapKnitter.Class.extend({
    
      initialize: function (options) {
        this._zoom = options.zoom || 0;
        this._latlng = L.latLng(options.latlng);
    Severity: Minor
    Found in app/assets/javascripts/mapknitter/Map.js - About 2 hrs to fix

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

          map.on('draw:edited', function(event) {
            var layers = event.layers;
      
            /* Update each record via AJAX request; see MapKnitter.Resources#update. */
            layers.eachLayer(function(layer) {
      Severity: Major
      Found in app/assets/javascripts/mapknitter/Annotations.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/mapknitter/Annotations.js on lines 79..86

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

      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

          map.on('draw:deleted', function(event) {
            var layers = event.layers;
      
            /* Delete each record via AJAX request; see MapKnitter.Resources#delete. */
            layers.eachLayer(function(layer) {
      Severity: Major
      Found in app/assets/javascripts/mapknitter/Annotations.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/mapknitter/Annotations.js on lines 70..77

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

      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

      Class MapsController has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class MapsController < ApplicationController
        protect_from_forgery except: :export
      
        before_action :require_login, only: %i(update destroy)
        before_action :require_login_or_anon, only: %i(edit)
      Severity: Minor
      Found in app/controllers/maps_controller.rb - About 2 hrs to fix

        File map.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class Map < ApplicationRecord
          include ActiveModel::Validations
          extend FriendlyId
          friendly_id :name, use: %i(slugged static)
        
        
        Severity: Minor
        Found in app/models/map.rb - About 2 hrs to fix

          Method openid_authentication has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def openid_authentication(openid_url, back_to)
              # puts openid_url
              authenticate_with_open_id(openid_url, required: %i(nickname email fullname)) do |result, identity_url, registration|
                dummy_identity_url = identity_url
                dummy_identity_url = dummy_identity_url.split('/')
          Severity: Minor
          Found in app/controllers/sessions_controller.rb - About 1 hr to fix

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

                  failed: function(response) {
                    Knitter.save.state = false
                    $('save_saved').hide()
                    $('save_saving').hide()
                    $('save_failed').show()
            Severity: Major
            Found in app/assets/javascripts/knitter.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/knitter.js on lines 8..14

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

            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

            Method best_cm_per_pixel has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def best_cm_per_pixel
                hist = images_histogram
                scores = []
                (0..(hist.length - 1)).each do |i|
                  scores[i] = 0
            Severity: Minor
            Found in app/models/map.rb - 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

            Method average_cm_per_pixel has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def average_cm_per_pixel
                if !warpables.empty?
                  scales = []
                  count = 0
                  average = 0
            Severity: Minor
            Found in app/models/map.rb - 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

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

                  saved: function(response) {
                    Knitter.save.state = true
                    $('save_saved').show()
                    $('save_saving').hide()
                    $('save_failed').hide()
            Severity: Major
            Found in app/assets/javascripts/knitter.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/knitter.js on lines 21..27

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

            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

                _deleteResource: function(resource, callback) {
                    var options = this._postDefaults(resource, 'DELETE', callback);
            
                    options.url = this._resourcesUrl + this.stampResource(resource);
            
            
            Severity: Major
            Found in app/assets/javascripts/mapknitter/core/Resources.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/mapknitter/core/Resources.js on lines 72..78

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

            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

                _updateResource: function(resource, callback) {
                    var options = this._postDefaults(resource, 'PUT', callback);
            
                    options.url = this._resourcesUrl + this.stampResource(resource);
            
            
            Severity: Major
            Found in app/assets/javascripts/mapknitter/core/Resources.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/mapknitter/core/Resources.js on lines 80..86

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

            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 setupGeocode has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              setupGeocode: function (e) {
                var img = e.layer,
                    geo = img.geocoding;
            
                L.DomEvent.on(img._image, 'load', function () {
            Severity: Minor
            Found in app/assets/javascripts/mapknitter/Map.js - About 1 hr to fix

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

                geocodeImage: function (img, fn, id) {
                  EXIF.getData(img, function () {
                    var GPS = EXIF.getAllTags(img);
              
                    /* If the lat/lng is available. */
              Severity: Minor
              Found in app/assets/javascripts/mapknitter/Map.js - About 1 hr to fix

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

                    export_options: function() {
                      Knitter.export_hide_tabs();
                      $('export_normal').show();
                      $('export_options').show();
                      $('export_options_tab').addClassName('active');
                Severity: Major
                Found in app/assets/javascripts/knitter.js and 2 other locations - About 1 hr to fix
                app/assets/javascripts/knitter.js on lines 379..384
                app/assets/javascripts/knitter.js on lines 391..396

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

                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

                    export_multispectral: function() {
                      Knitter.export_hide_tabs();
                      $('export_normal').hide();
                      $('export_multispectral').show();
                      $('export_multispectral_tab').addClassName('active');
                Severity: Major
                Found in app/assets/javascripts/knitter.js and 2 other locations - About 1 hr to fix
                app/assets/javascripts/knitter.js on lines 379..384
                app/assets/javascripts/knitter.js on lines 385..390

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

                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

                    export_intro: function() {
                      Knitter.export_hide_tabs();
                      $('export_normal').show();
                      $('export_intro').show();
                      $('export_intro_tab').addClassName('active');
                Severity: Major
                Found in app/assets/javascripts/knitter.js and 2 other locations - About 1 hr to fix
                app/assets/javascripts/knitter.js on lines 385..390
                app/assets/javascripts/knitter.js on lines 391..396

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

                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 find_map_center has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    find_map_center: function() {
                      if (warpables.length > 0) {
                        var latsum = 0, lonsum = 0, latcount = 0, loncount = 0
                        var maxlat = 0,maxlon = 0,minlat = 0,minlon = 0
                        warpables.each(function(warpable){
                Severity: Minor
                Found in app/assets/javascripts/knitter.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language