publiclab/mapknitter

View on GitHub

Showing 52 of 127 total issues

File Map.js has 555 lines of code (exceeds 250 allowed). Consider refactoring.
Open

MapKnitter.Map = MapKnitter.Class.extend({

  initialize: function (options) {
    this._zoom = options.zoom || 0;
    this._latlng = L.latLng(options.latlng);
Severity: Major
Found in app/assets/javascripts/mapknitter/Map.js - About 1 day to fix

    File knitter.js has 349 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Legacy!
    jQuery(document).ready(function($) {
      var Knitter = {
        // start storing a layer_type and layer_url in Map model, use it to switch this:
        openlayers_on: false,
    Severity: Minor
    Found in app/assets/javascripts/knitter.js - About 4 hrs to fix

      Class Map has 33 methods (exceeds 20 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 4 hrs to fix

        Function initialize has 101 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          initialize: function (options) {
            this._zoom = options.zoom || 0;
            this._latlng = L.latLng(options.latlng);
            this.map_id = options.map_id || 0;
            this.readOnly = options.readOnly;
        Severity: Major
        Found in app/assets/javascripts/mapknitter/Map.js - About 4 hrs to fix

          Function start_openlayers has 91 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              start_openlayers: function(layer,tile_url,tile_layer) {
                if (layer == "none") $('map').hide()
                else $('map').show()
                if (!Knitter.openlayers_on) Knitter.init_openlayers(layer)
                // http://isse.cr.usgs.gov/ArcGIS/services/Combined/TNM_Large_Scale_Imagery/MapServer/WMSServer?request=GetCapabilities&service=WMS
          Severity: Major
          Found in app/assets/javascripts/knitter.js - About 3 hrs to fix

            Method openid_authentication has a Cognitive Complexity of 25 (exceeds 5 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 3 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 geocodeImage has a Cognitive Complexity of 24 (exceeds 5 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 3 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 exports has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(grunt) {
            
                require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
            
                grunt.initConfig({
            Severity: Major
            Found in app/assets/Gruntfile.js - About 3 hrs to fix

              Function setupCollection has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                setupCollection: function() {
              
                  map._imgGroup = L.distortableCollection({
                    editable: !mapknitter.readOnly,
                    exportOpts: {
              Severity: Major
              Found in app/assets/javascripts/mapknitter/Map.js - About 2 hrs to fix

                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

                    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

                          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

                          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

                          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

                              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