seb86/Auto-Load-Next-Post

View on GitHub
assets/js/admin/scanner.js

Summary

Maintainability
F
3 days
Test Coverage

File scanner.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global alnp_scanner_params */
( function( $, params ) {

    var step                 = '',
        search_finished      = true,
Severity: Minor
Found in assets/js/admin/scanner.js - About 2 hrs to fix

    Function search_elements has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function search_elements( action ) {
            $.ajax({
                method: "GET",
                url: request_url + '?action=' + action,
                dataType: 'json',
    Severity: Major
    Found in assets/js/admin/scanner.js - About 2 hrs to fix

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

                  success: function( data ) {
                      $(data).each( function( index, selector ) {
                          var element = $(post).find(selector);
      
                          // Check if element was found in post.
      Severity: Major
      Found in assets/js/admin/scanner.js - About 2 hrs to fix

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

            function checkPendingRequest() {
                if ( $.active > 0 ) {
                    window.setTimeout(checkPendingRequest, 8000);
                }
                else {
        Severity: Minor
        Found in assets/js/admin/scanner.js - About 1 hr to fix

          Function scan_theme_selectors has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function scan_theme_selectors( timeout ) {
                  $.get( params.random_page, function( response ) {
                      if ( ! response ) {
                          return;
                      }
          Severity: Minor
          Found in assets/js/admin/scanner.js - About 1 hr to fix

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

                function find_template_location() {
                    var $data = {
                        action: 'alnp_find_template_location',
                    };
            
            
            Severity: Minor
            Found in assets/js/admin/scanner.js - About 1 hr to fix

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

                                      if ( action == 'alnp_get_title_selectors' && post_title == '' ) {
                                          $('.selectors').find('.title').removeClass('pending').addClass('found');
                                          $('.results-found').find('.title').addClass('found');
                                          $('.results-found').find('.title span.result').html('<code title="' + params.i18n_copy_title + '">' + selector + '</code>');
                                          post_title = selector;
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 4 hrs to fix
              assets/js/admin/scanner.js on lines 212..218

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

              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 ( action == 'alnp_get_container_selectors' && content_container == '' ) {
                                          $('.selectors').find('.container').removeClass('pending').addClass('found');
                                          $('.results-found').find('.container').addClass('found');
                                          $('.results-found').find('.container span.result').html('<code title="' + params.i18n_copy_title + '">' + selector + '</code>');
                                          content_container = selector;
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 4 hrs to fix
              assets/js/admin/scanner.js on lines 220..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 134.

              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

                                  jc = $.dialog({
                                      icon: 'dashicons dashicons-search',
                                      title: params.i18n_scanning_theme,
                                      content: '<p>' + params.i18n_scanning_theme_content + '</p>',
                                      rtl: rtl,
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 2 hrs to fix
              assets/js/admin/scanner.js on lines 327..337

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

              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

                                  jc = $.dialog({
                                      icon: 'dashicons dashicons-warning',
                                      title: params.i18n_post_nav_missing,
                                      content: '<p>' + params.i18n_error_post_nav + '</p>',
                                      rtl: rtl,
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 2 hrs to fix
              assets/js/admin/scanner.js on lines 173..183

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

              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 ( response !== -1 ) {
                              $('.template-location-results .meter').removeClass('blue').removeClass('animate');
                          } else {
                              $('.template-location-results .meter').removeClass('blue').addClass('red').removeClass('animate');
                          }
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 1 hr to fix
              assets/js/admin/scanner.js on lines 114..118

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

              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 ( response !== -1 ) {
                              $('.enter .meter').removeClass('blue').removeClass('animate');
                          } else {
                              $('.enter .meter').removeClass('blue').addClass('red').removeClass('animate');
                          }
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 1 hr to fix
              assets/js/admin/scanner.js on lines 154..158

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

              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 ( action == 'alnp_get_container_selectors' && content_container == '' ) {
                                          $('.results-found').find('.container').removeClass('pending').addClass('not-found');
                                          selectors_undetected = selectors_undetected+1;
                                      }
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 1 hr to fix
              assets/js/admin/scanner.js on lines 270..273

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

              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 ( action == 'alnp_get_comment_selectors' && comment_container == '' ) {
                                          $('.results-found').find('.comments').removeClass('pending').addClass('not-found');
                                          selectors_undetected = selectors_undetected+1;
                                      }
              Severity: Major
              Found in assets/js/admin/scanner.js and 1 other location - About 1 hr to fix
              assets/js/admin/scanner.js on lines 252..255

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

              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