hack4impact/maps4all

View on GitHub
app/assets/scripts/map.js

Summary

Maintainability
D
2 days
Test Coverage

File map.js has 560 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// This JS file is for the map and list view creations on the homepage of the
// Maps4All site for the user. This example requires the Places library. Include
// the libraries=places parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">

Severity: Major
Found in app/assets/scripts/map.js - About 1 day to fix

    Function displayDetailedResourceView has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function displayDetailedResourceView(marker) {
      // get descriptor information as associations
      $.get('get-associations/' + marker.resourceID).done(function(associations) {
    
        $("#map").hide();
    Severity: Major
    Found in app/assets/scripts/map.js - About 3 hrs to fix

      Function markerListener has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function markerListener(marker, event) {
        $('.list-resource').removeClass('list-selected');
        $('#map').show();
        $('#resource-info').hide();
      
      
      Severity: Minor
      Found in app/assets/scripts/map.js - About 1 hr to fix

        Function initLocationSearch has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function initLocationSearch(map) {
          var input = document.getElementById('pac-input');
          var autocomplete = new google.maps.places.Autocomplete(input);
          autocomplete.bindTo('bounds', map);
        
        
        Severity: Minor
        Found in app/assets/scripts/map.js - About 1 hr to fix

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

          function createLocationMarker(marker_info){
            if (!locationMarker) {
                locationMarker = new google.maps.Marker({
                  map: map,
                  position: marker_info.location,
          Severity: Minor
          Found in app/assets/scripts/map.js - About 1 hr to fix

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

            function populateListDiv() {
              var markersToShow = markers;
              $("#list").empty();
            
              var listResources = [];
            Severity: Minor
            Found in app/assets/scripts/map.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  if (place.address_components) {
                    address = [
                      ((place.address_components[0] &&
                        place.address_components[0].short_name) || ''),
                      ((place.address_components[1] &&
              Severity: Major
              Found in app/assets/scripts/map.js - About 1 hr to fix

                Function makeResponsive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function makeResponsive() {
                  setInitialZoom();
                
                  // Change to a single column view
                  if ($(window).width() <= singleColNoSpaceBreakpoint) {
                Severity: Minor
                Found in app/assets/scripts/map.js - About 25 mins 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

                There are no issues that match your filters.

                Category
                Status