seb86/Auto-Load-Next-Post

View on GitHub

Showing 140 of 140 total issues

Function add_notices has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

        public function add_notices() {
            global $current_user;

            // If the current user can not install plugins then return nothing!
            if ( ! current_user_can( 'install_plugins' ) ) {
Severity: Minor
Found in includes/admin/class-alnp-admin-notices.php - About 3 hrs 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

Method alnp_get_customizer_controls has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function alnp_get_customizer_controls() {
            /**
             * Filter Customizer controls for Auto Load Next Post.
             *
             * @param array $controls Customizer controls to add.
Severity: Major
Found in includes/customizer/class-alnp-customizer.php - About 3 hrs to fix

    Method alnp_get_customizer_settings has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function alnp_get_customizer_settings() {
                $settings = $this->alnp_get_settings();
    
                /**
                 * Filter Customizer settings for Auto Load Next Post.
    Severity: Major
    Found in includes/customizer/class-alnp-customizer.php - About 3 hrs to fix

      Function auto_load_next_post has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function auto_load_next_post() {
              // If the user can not read any more then stop looking for new posts.
              if ( stop_reading ) {
                  return;
              }
      Severity: Major
      Found in assets/js/frontend/auto-load-next-post.dev.js - About 3 hrs to fix

        Method save_fields has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public static function save_fields( $options ) {
                    if ( empty( $_POST ) ) {
                        return false;
                    }
        
        
        Severity: Major
        Found in includes/admin/class-alnp-admin-settings.php - About 3 hrs to fix

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

                  if ( post_url.indexOf( '?p=' ) > -1 ) {
                      np_url = post_url + '&alnp=1';
                  } else {
                      var partial_endpoint = 'alnp/';
          
          
          Severity: Major
          Found in assets/js/frontend/auto-load-next-post.dev.js and 1 other location - About 2 hrs to fix
          assets/js/frontend/auto-load-next-post.js on lines 328..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 93.

          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 ( post_url.indexOf( '?p=' ) > -1 ) {
                      np_url = post_url + '&alnp=1';
                  } else {
                      var partial_endpoint = 'alnp/';
          
          
          Severity: Major
          Found in assets/js/frontend/auto-load-next-post.js and 1 other location - About 2 hrs to fix
          assets/js/frontend/auto-load-next-post.dev.js on lines 388..397

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

          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 run_alnp has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function run_alnp() {
                  if ( $( 'article' ).length <= 0 ) {
                      article_container = 'div';
                  }
          
          
          Severity: Major
          Found in assets/js/frontend/auto-load-next-post.js - About 2 hrs to fix

            File auto-load-next-post.dev.js has 282 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            // Variables
            var version             = auto_load_next_post_params.alnp_version,
                content_container   = auto_load_next_post_params.alnp_content_container,
                post_title_selector = auto_load_next_post_params.alnp_title_selector,
                nav_container       = auto_load_next_post_params.alnp_navigation_container,
            Severity: Minor
            Found in assets/js/frontend/auto-load-next-post.dev.js - About 2 hrs to fix

              Function alnp_scan_directories has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  function alnp_scan_directories( $post_type = 'post', $post_format = '' ) {
                      // Possible locations where the content files are found.
                      $locations = alnp_get_locations();
              
                      // Templates to look for based on the post that is loaded.
              Severity: Minor
              Found in includes/auto-load-next-post-template-functions.php - About 2 hrs 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

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

              <?php
              /**
               * Auto Load Next Post Theme Support: Make
               *
               * Applies support for The Theme Foundry Make Theme.
              Severity: Major
              Found in includes/theme-support/class-alnp-make.php and 1 other location - About 2 hrs to fix
              includes/theme-support/class-alnp-twentyten.php on lines 1..69

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

              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

              <?php
              /**
               * Auto Load Next Post Theme Support: Twenty Ten
               *
               * Applies support for WordPress Twenty Ten Theme.
              Severity: Major
              Found in includes/theme-support/class-alnp-twentyten.php and 1 other location - About 2 hrs to fix
              includes/theme-support/class-alnp-make.php on lines 1..69

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

              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

              Method add_debug_info has 66 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public function add_debug_info( $debug_info ) {
                          $debug_info['auto-load-next-post'] = array(
                              'label'    => esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ),
                              'fields'   => array(
                                  // Theme Selectors
              Severity: Major
              Found in includes/admin/class-alnp-admin-site-health.php - About 2 hrs to fix

                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

                  Method get_settings has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          public function get_settings() {
                              return apply_filters(
                                  'alnp_misc_settings', array(
                  
                                      'title' => array(
                  Severity: Major
                  Found in includes/admin/settings/class-alnp-settings-misc.php - About 2 hrs to fix

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

                                if ( remove_comments === 'yes' ) {
                                    $( comments_container ).remove();
                    
                                    // Remove Disqus comments if found.
                                    if ( $( '#disqus_thread' ).length > 0 ) {
                    Severity: Major
                    Found in assets/js/frontend/auto-load-next-post.dev.js and 1 other location - About 2 hrs to fix
                    assets/js/frontend/auto-load-next-post.dev.js on lines 118..129

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

                    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 ( remove_comments === 'yes' ) {
                                $( comments_container ).remove();
                    
                                // Remove Disqus comments if found.
                                if ( $( '#disqus_thread' ).length > 0 ) {
                    Severity: Major
                    Found in assets/js/frontend/auto-load-next-post.dev.js and 1 other location - About 2 hrs to fix
                    assets/js/frontend/auto-load-next-post.dev.js on lines 438..449

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

                    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 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 auto_load_next_post_seconds_to_words has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                          function auto_load_next_post_seconds_to_words( $seconds ) {
                              // Get the years.
                              $years = ( intval( $seconds ) / YEAR_IN_SECONDS ) % 100;
                              if ( $years > 1 ) {
                                  /* translators: Number of years */
                      Severity: Minor
                      Found in includes/auto-load-next-post-formatting-functions.php - About 2 hrs 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 alnp_init_customizer has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                              public function alnp_init_customizer( $wp_customize ) {
                                  /**
                                   * Dont add settings to the customizer if the user does
                                   * not have permission to make changes to the theme.
                                   */
                      Severity: Minor
                      Found in includes/customizer/class-alnp-customizer.php - About 2 hrs 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

                      Severity
                      Category
                      Status
                      Source
                      Language