seb86/Auto-Load-Next-Post

View on GitHub

Showing 140 of 140 total issues

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

                <?php if ( get_the_author_meta( 'description' ) && ( ! function_exists( 'is_multi_author' ) || is_multi_author() ) ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries ?>
                <div id="author-info">
                    <div id="author-avatar">
                        <?php
                        /** This filter is documented in author.php */
Severity: Major
Found in templates/theme-support/twentyeleven/content-alnp.php and 1 other location - About 2 hrs to fix
templates/theme-support/twentyten/content-alnp.php on lines 35..58

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

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

        public function admin_scripts() {
            $screen    = get_current_screen();
            $screen_id = $screen ? $screen->id : '';

            if ( $screen_id == 'settings_page_auto-load-next-post' ) {
Severity: Major
Found in includes/admin/class-alnp-admin-assets.php - About 2 hrs to fix

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

                <?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries  ?>
                <div id="entry-author-info">
                    <div id="author-avatar">
    
                        <?php
    Severity: Major
    Found in templates/theme-support/twentyten/content-alnp.php and 1 other location - About 2 hrs to fix
    templates/theme-support/twentyeleven/content-alnp.php on lines 64..82

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

    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 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 auto_load_next_post has 55 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.js - About 2 hrs to fix

        Method alnp_init_customizer has 53 lines of code (exceeds 25 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: Major
        Found in includes/customizer/class-alnp-customizer.php - About 2 hrs to fix

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

              function scrollspy() {
                  // Do not enter once the initial post has loaded.
                  if ( post_count > 0 ) {
                      $( 'hr[data-powered-by="alnp"]' ).on( 'scrollSpy:enter', alnp_enter );
                  }
          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 208..216

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

          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

              function scrollspy() {
                  // Do not enter once the initial post has loaded.
                  if ( post_count > 0 ) {
                      $( 'hr[data-powered-by="alnp"]' ).on( 'scrollSpy:enter', alnp_enter );
                  }
          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 253..261

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

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

                  public function get_settings() {
                      $settings = array();
          
                      $description = sprintf( __( 'This helps fine tune %s to locate your theme templates directory in order to display content in the same style as your theme.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) );
          
          
          Severity: Minor
          Found in includes/admin/settings/class-alnp-settings-templates.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 update_alnp_theme_selectors has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public function update_alnp_theme_selectors( $stylesheet = '', $old_theme = false ) {
                  // Check if Auto Load Next Post is supported before updating the theme selectors.
                  if ( is_alnp_supported() ) {
                      $theme_support = get_theme_support( 'auto-load-next-post' );
          
          
          Severity: Minor
          Found in includes/theme-support/class-alnp-theme-support.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

                              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

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

                  public function get_settings() {
                      $settings = array();
          
                      $description = sprintf( __( 'This helps fine tune %s to locate your theme templates directory in order to display content in the same style as your theme.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) );
          
          
          Severity: Minor
          Found in includes/admin/settings/class-alnp-settings-templates.php - About 2 hrs to fix

            Method output has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function output( $current_view ) {
                        if ( $current_view !== 'getting-started' ) {
                            return;
                        }
            
            
            Severity: Minor
            Found in includes/admin/class-alnp-getting-started.php - About 1 hr to fix

              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

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

                    function alnp_template_redirect() {
                        global $wp_query;
                
                        // If this is not a request for alnp or a singular object then bail.
                        if ( ! isset( $wp_query->query_vars['alnp'] ) || ! is_singular() ) {
                Severity: Minor
                Found in includes/auto-load-next-post-template-functions.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 get_settings has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                        public function get_settings() {
                            global $blog_id;
                
                            $settings = array();
                
                
                Severity: Minor
                Found in includes/admin/settings/class-alnp-settings-theme-selectors.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 load_file has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                        public static function load_file( $name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false ) {
                            $url = AUTO_LOAD_NEXT_POST_URL_PATH . $file_path; // URL to the file.
                
                            if ( file_exists( AUTO_LOAD_NEXT_POST_FILE_PATH . $file_path ) ) {
                                if ( $is_script ) {
                Severity: Minor
                Found in auto-load-next-post.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

                Severity
                Category
                Status
                Source
                Language