publiclab/mapknitter

View on GitHub
app/assets/javascripts/knitter.js

Summary

Maintainability
D
2 days
Test Coverage

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

    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

      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

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

            setup: function() {
              Glop.observe('glop:predraw', function() { $C.clear();})
              // disable default "delete" key (in Chrome it goes "back")
              window.addEventListener ('keydown', function (e) {
                // If the key pressed was a backspace key, handle it specially
        Severity: Minor
        Found in app/assets/javascripts/knitter.js - About 1 hr to fix

          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

                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

          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

          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_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

                      var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
          Severity: Minor
          Found in app/assets/javascripts/knitter.js and 2 other locations - About 35 mins to fix
          app/assets/javascripts/knitter.js on lines 262..262
          app/assets/javascripts/knitter.js on lines 408..408

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

          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

                      var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
          Severity: Minor
          Found in app/assets/javascripts/knitter.js and 2 other locations - About 35 mins to fix
          app/assets/javascripts/knitter.js on lines 263..263
          app/assets/javascripts/knitter.js on lines 408..408

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

          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

              var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
          Severity: Minor
          Found in app/assets/javascripts/knitter.js and 2 other locations - About 35 mins to fix
          app/assets/javascripts/knitter.js on lines 262..262
          app/assets/javascripts/knitter.js on lines 263..263

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

          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