dynamic/SilverStripe-Locator-Module

View on GitHub

Showing 42 of 74 total issues

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

/*! jQuery Google Maps Store Locator - v2.7.2 - 2016-12-03
* http://www.bjornblog.com/web/jquery-store-locator-plugin
* Copyright (c) 2016 Bjorn Holine; Licensed MIT */

;(function ($, window, document, undefined) {

Function processData has 247 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        processData: function (mappingObject, originPoint, data, page) {
            this.writeDebug('processData',arguments);
            var _this = this;
            var i = 0;
            var orig_lat, orig_lng, origin, name, maxDistance, marker, bounds, storeStart, storeNumToShow, myOptions, distError, openMap, infowindow;

Function processForm has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        processForm: function (e) {
            this.writeDebug('processForm',arguments);
            var _this = this,
                distance = null,
                $addressInput = $('#' + this.settings.addressID),

Function taxonomyFiltering has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        taxonomyFiltering: function() {
            this.writeDebug('taxonomyFiltering');
            var _this = this;

            // Set up the filters

Method init has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function init()
    {
        parent::init();

        // prevent init of map if no query
Severity: Major
Found in src/Page/LocatorController.php - About 2 hrs to fix

Function _getData has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _getData: function (lat, lng, address, geocodeData ) {
            this.writeDebug('_getData',arguments);
            var _this = this,
                northEast = '',
                southWest = '',

Function createMarker has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        createMarker: function (point, name, address, letter, map, category) {
            this.writeDebug('createMarker',arguments);
            var marker, markerImg, letterMarkerImg;
            var categories = [];

Function _start has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _start: function () {
            this.writeDebug('_start');
            var _this = this,
                    doAutoGeo = this.settings.autoGeocode,
                    latlng,

Consider simplifying this complex logical expression.
Open

                if (this.settings.disableAlphaMarkers === true || this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || this.settings.catMarkers !== null || this.settings.markerImg !== null || (this.settings.fullMapStart === true && firstRun === true && (isNaN(this.settings.fullMapStartListLimit) || this.settings.fullMapStartListLimit > 26 || this.settings.fullMapStartListLimit === -1))) {
                    marker = new google.maps.Marker({
                        position : point,
                        map      : map,
                        draggable: false,

Function init has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        init: function () {
            var _this = this;
            this.writeDebug('init');
            // Calculate geocode distance functions
            if (this.settings.lengthUnit === 'km') {

Function _loadTemplates has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _loadTemplates: function () {
            this.writeDebug('_loadTemplates');
            var source;
            var _this = this;
            var templateError = '<div class="bh-sl-error">Error: Could not load plugin templates. Check the paths and ensure they have been uploaded. Paths will be wrong if you do not run this from a web server.</div>';

Method setLocations has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setLocations(HTTPRequest $request = null)
    {

        if ($request === null) {
            $request = $this->request;
Severity: Minor
Found in src/Page/LocatorController.php - About 1 hr to fix

Function _defineLocationData has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _defineLocationData: function (currentMarker, storeStart, page) {
            this.writeDebug('_defineLocationData',arguments);
            var indicator = '';
            this._createLocationVariables(currentMarker.get('id'));

Function setLocations has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function setLocations(HTTPRequest $request = null)
    {

        if ($request === null) {
            $request = $this->request;
Severity: Minor
Found in src/Page/LocatorController.php - 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 mapping has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        mapping: function (mappingObject) {
            this.writeDebug('mapping',arguments);
            var _this = this;
            var orig_lat, orig_lng, geocodeData, origin, originPoint, page;
            if (!this.isEmptyObject(mappingObject)) {

Method getCMSFields has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
            $fields->addFieldsToTab(
                'Root.Main',
Severity: Minor
Found in src/Page/LocationPage.php - About 1 hr to fix

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

        autoGeocodeQuery: function (position) {
            this.writeDebug('autoGeocodeQuery',arguments);
            var _this = this,
                distance = null,
                $distanceInput = $('#' + this.settings.maxDistanceID),

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

        defaultLocation: function() {
            this.writeDebug('defaultLocation');
            var _this = this,
                distance = null,
                $distanceInput = $('#' + this.settings.maxDistanceID),

Function migrateLocations has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function migrateLocations()
    {
        if (!$parent = Locator::get()->first()) {
            $parent = Locator::create();
            $parent->Title = "Locator";
Severity: Minor
Found in src/Tasks/LocationToPageTask.php - 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

Consider simplifying this complex logical expression.
Open

            if (this.settings.disableAlphaMarkers === true || this.settings.storeLimit === -1 || this.settings.storeLimit > 26 || (this.settings.fullMapStart === true && firstRun === true && (isNaN(this.settings.fullMapStartListLimit) || this.settings.fullMapStartListLimit > 26 || this.settings.fullMapStartListLimit === -1))) {
                indicator = markerId + 1;
            }
            else {
                if (page > 0) {
Severity
Category
Status
Source
Language