app/assets/scripts/map.js
File map.js
has 560 lines of code (exceeds 250 allowed). Consider refactoring. Open
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">
Function displayDetailedResourceView
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function displayDetailedResourceView(marker) {
// get descriptor information as associations
$.get('get-associations/' + marker.resourceID).done(function(associations) {
$("#map").hide();
Function markerListener
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function markerListener(marker, event) {
$('.list-resource').removeClass('list-selected');
$('#map').show();
$('#resource-info').hide();
Function initLocationSearch
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function initLocationSearch(map) {
var input = document.getElementById('pac-input');
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
Function createLocationMarker
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createLocationMarker(marker_info){
if (!locationMarker) {
locationMarker = new google.maps.Marker({
map: map,
position: marker_info.location,
Function populateListDiv
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function populateListDiv() {
var markersToShow = markers;
$("#list").empty();
var listResources = [];
Consider simplifying this complex logical expression. Open
Open
if (place.address_components) {
address = [
((place.address_components[0] &&
place.address_components[0].short_name) || ''),
((place.address_components[1] &&
Function makeResponsive
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
function makeResponsive() {
setInitialZoom();
// Change to a single column view
if ($(window).width() <= singleColNoSpaceBreakpoint) {
- Read upRead up
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"