dynamic/SilverStripe-Locator-Module

View on GitHub

Showing 74 of 74 total issues

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

            if(this.settings.querystringParams === true) {
                // Check for query string parameters
                if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID) || this.getQueryString(this.settings.maxDistanceID)){
                    addressInput = this.getQueryString(this.settings.addressID);
                    searchInput = this.getQueryString(this.settings.searchID);
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1524..1548

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

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

            $('#' + this.settings.taxonomyFilters[key] + ' select').each(function () {
                var filterVal = $(this).val();

                // Only add the taxonomy id if it doesn't already exist
                if (typeof filterVal !== 'undefined' && filterVal !== '' &&  filters[key].indexOf(filterVal) === -1) {
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1720..1727

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

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

                if ($(this).prop('checked')) {
                    var filterVal = $(this).val();

                    // Only add the taxonomy id if it doesn't already exist
                    if (typeof filterVal !== 'undefined' && filterVal !== '' && filters[key].indexOf(filterVal) === -1) {
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1702..1709

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

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

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,

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

                if (page > 0) {
                    indicator = String.fromCharCode('A'.charCodeAt(0) + (storeStart + markerId));
                }
                else {
                    indicator = String.fromCharCode('A'.charCodeAt(0) + markerId);
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 2580..2585

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

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

                if (page > 0) {
                    letter = String.fromCharCode('A'.charCodeAt(0) + (storeStart + y));
                }
                else {
                    letter = String.fromCharCode('A'.charCodeAt(0) + y);
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1129..1134

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

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

            if (_this.settings.storeLimit === -1 || locationset.length < _this.settings.storeLimit || (this.settings.fullMapStart === true && firstRun === true && (isNaN(this.settings.fullMapStartListLimit) || this.settings.fullMapStartListLimit > 26 || this.settings.fullMapStartListLimit === -1))) {
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1064..1064
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1125..1125

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

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

                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))) {
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1125..1125
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 2476..2476

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

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

            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))) {
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 1064..1064
thirdparty/jquery-store-locator-plugin/assets/js/plugins/storeLocator/jquery.storelocator.js on lines 2476..2476

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

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

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),
Severity
Category
Status
Source
Language