volontariat/voluntary

View on GitHub
app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js

Summary

Maintainability
D
2 days
Test Coverage

File jquery.location_picker.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function ( $ ) {

    /**
     * Holds google map object and related utility entities.
     * @constructor

    Function locationpicker has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.locationpicker = function( options, params ) {
            if (typeof options == 'string') { // Command provided
                var _targetDomElement = this.get(0);
                // Plug-in is not applied - nothing to do.
                if (!isPluginApplied(_targetDomElement)) return;

      Function setupInputListenersInput has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function setupInputListenersInput(inputBinding, gmapContext) {
              if (inputBinding) {
                  if (inputBinding.radiusInput){
                      inputBinding.radiusInput.on("change", function(e) {
                          if (!e.originalEvent) { return }

        Function GMapContext has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function GMapContext(domElement, options) {
                var _map = new google.maps.Map(domElement, options);
                var _marker = new google.maps.Marker({
                    position: new google.maps.LatLng(54.19335, -3.92695),
                    map: _map,

          Function address_component_from_google_geocode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  address_component_from_google_geocode: function(address_components) {
                      var result = {};
                      for (var i = address_components.length-1; i>=0; i--) {
                          var component = address_components[i];
                          // Postal code

            Avoid deeply nested control flow statements.
            Open

                                            if(status == google.maps.GeocoderStatus.OK  && results && results.length) {
                                                GmUtility.setPosition(gmapContext, results[0].geometry.location, function(context) {
                                                    updateInputValues(inputBinding, context);
                                                    context.settings.onchanged.apply(gmapContext.domContainer,
                                                        [GmUtility.locationFromLatLng(context.location), context.radius, false]);
            Severity: Major
            Found in app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return this;
              Severity: Major
              Found in app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                        return {
                                            map: gmapContext.map,
                                            marker: gmapContext.marker,
                                            location: locationObj
                                        }
                Severity: Major
                Found in app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                          return null;
                  Severity: Major
                  Found in app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return this.each(function() {
                                var $target = $(this);
                                // If plug-in hasn't been applied before - initialize, otherwise - skip
                                if (isPluginApplied(this)){
                                  updateMap(getContextForElement(this), $(this), options);
                    Severity: Major
                    Found in app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return null;
                      Severity: Major
                      Found in app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js - About 30 mins to fix

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

                                            GmUtility.setPosition(gmapContext, place.geometry.location, function(context) {
                                                updateInputValues(inputBinding, context);
                                                context.settings.onchanged.apply(gmapContext.domContainer,
                                                    [GmUtility.locationFromLatLng(context.location), context.radius, false]);
                                            });
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 208..212

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

                        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

                                                            GmUtility.setPosition(gmapContext, results[0].geometry.location, function(context) {
                                                                updateInputValues(inputBinding, context);
                                                                context.settings.onchanged.apply(gmapContext.domContainer,
                                                                    [GmUtility.locationFromLatLng(context.location), context.radius, false]);
                                                            });
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 189..193

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

                        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 3 locations. Consider refactoring.
                        Open

                                            GmUtility.setPosition(gmapContext, new google.maps.LatLng($(this).val(), gmapContext.location.lng()), function(context){
                                                context.settings.onchanged.apply(gmapContext.domContainer,
                                                    [GmUtility.locationFromLatLng(context.location), context.radius, false]);
                                            });
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 173..176
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 232..235

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

                        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 3 locations. Consider refactoring.
                        Open

                                            GmUtility.setPosition(gmapContext, new google.maps.LatLng(gmapContext.location.lat(), $(this).val()), function(context){
                                                context.settings.onchanged.apply(gmapContext.domContainer,
                                                    [GmUtility.locationFromLatLng(context.location), context.radius, false]);
                                            });
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 173..176
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 223..226

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

                        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 3 locations. Consider refactoring.
                        Open

                                            GmUtility.setPosition(gmapContext, gmapContext.location, function(context){
                                                context.settings.onchanged.apply(gmapContext.domContainer,
                                                    [GmUtility.locationFromLatLng(context.location), context.radius, false]);
                                            });
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 223..226
                        app/assets/javascripts/voluntary/optional_lib/jquery.location_picker.js on lines 232..235

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

                        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