seb86/Auto-Load-Next-Post

View on GitHub

Showing 140 of 140 total issues

Function set_theme_selectors has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        private static function set_theme_selectors() {
            if ( is_alnp_supported() ) {
                $content_container    = alnp_get_theme_support( 'content_container' );
                $title_selector       = alnp_get_theme_support( 'title_selector' );
                $navigation_container = alnp_get_theme_support( 'navigation_container' );
Severity: Minor
Found in includes/class-alnp-install.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 alnp_find_template has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    function alnp_find_template( $location = '', $post_type, $post_format ) {
        // Templates to look for based on the post that is loaded.
        $templates = alnp_get_templates( $post_type, $post_format );

        $found = false;
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

Method add_notices has 41 lines of code (exceeds 25 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 1 hr to fix

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

                $settings[] = array(
                    'title'       => esc_html__( 'Post Title', 'auto-load-next-post' ),
                    'desc'        => sprintf( __( 'Used to identify which article the user is reading and track should Google Analytics or other analytics be enabled. %s', 'auto-load-next-post' ), $post_title_default ),
                    'id'          => 'auto_load_next_post_title_selector',
                    'default'     => 'h1.entry-title',
    includes/admin/settings/class-alnp-settings-theme-selectors.php on lines 150..161
    includes/admin/settings/class-alnp-settings-theme-selectors.php on lines 190..201

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

    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

                $settings[] = array(
                    'title'       => esc_html__( 'Content Container', 'auto-load-next-post' ),
                    'desc'        => sprintf( __( 'The primary container where the post content is loaded in. %s', 'auto-load-next-post' ), $container_default ),
                    'id'          => 'auto_load_next_post_content_container',
                    'default'     => 'main.site-main',
    includes/admin/settings/class-alnp-settings-theme-selectors.php on lines 170..181
    includes/admin/settings/class-alnp-settings-theme-selectors.php on lines 190..201

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

    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

                $settings[] = array(
                    'title'       => esc_html__( 'Post Navigation', 'auto-load-next-post' ),
                    'desc'        => sprintf( __( 'Used to identify which post to load next if any. %s', 'auto-load-next-post' ), $post_navigation_default ),
                    'id'          => 'auto_load_next_post_navigation_container',
                    'default'     => 'nav.post-navigation',
    includes/admin/settings/class-alnp-settings-theme-selectors.php on lines 150..161
    includes/admin/settings/class-alnp-settings-theme-selectors.php on lines 170..181

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

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

            public function output( $current_view ) {
                if ( $current_view !== 'setup-wizard' ) {
                    return;
                }
    
    
    Severity: Minor
    Found in includes/admin/class-alnp-setup-wizard.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 alnp_remove_widgets_panel has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            public function alnp_remove_widgets_panel( $components ) {
                if ( $this->alnp_is_customizer() ) {
                    foreach( $components as $key => $component ) {
                        if ( $component == 'widgets' ) {
                            unset( $components[ 'widgets' ] );
    Severity: Minor
    Found in includes/customizer/class-alnp-customizer.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 alnp_load_content has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        function alnp_load_content( $post_type, $post_format ) {
            // Returns template location for supported themes.
            $template_location = alnp_template_location();
    
            $content_found = false;
    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 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

      Method auto_load_next_post_seconds_to_words has 36 lines of code (exceeds 25 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 1 hr to fix

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

                public function dont_bug_me() {
                    global $current_user;
        
                    $user_hidden_notice = false;
        
        
        Severity: Minor
        Found in includes/admin/class-alnp-admin-notices.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_option has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                public static function get_option( $option_name, $default = '' ) {
                    // Array value
                    if ( strstr( $option_name, '[' ) ) {
                        parse_str( $option_name, $option_array );
        
        
        Severity: Minor
        Found in includes/admin/class-alnp-admin-settings.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

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

                                $( 'html, body' ).animate({ scrollTop: (previous_post.offset().top - 100) }, 1000, function() {
                                    $( 'body' ).trigger( 'alnp-previous-post', [ previous_post ] );
                                });
        Severity: Major
        Found in assets/js/frontend/auto-load-next-post.js and 1 other location - About 1 hr to fix
        assets/js/frontend/auto-load-next-post.dev.js on lines 235..237

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

        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

                                $( 'html, body' ).animate({ scrollTop: (previous_post.offset().top - 100) }, 1000, function() {
                                    $( 'body' ).trigger( 'alnp-previous-post', [ previous_post ] );
                                });
        Severity: Major
        Found in assets/js/frontend/auto-load-next-post.dev.js and 1 other location - About 1 hr to fix
        assets/js/frontend/auto-load-next-post.js on lines 190..192

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

        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

        Method render_content has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function render_content() {
                    ?>
                    <span class="customize-control-title"><?php echo $this->label; ?></span>
        
                    <p>
        Severity: Minor
        Found in includes/customizer/class-alnp-pro-preview-controller.php - About 1 hr to fix

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

                  if ( ( offset.top - scrollTop ) <= 200 && curr_url != this_url ) {
                      curr_url = this_url;
          
                      // Update the History ONLY if we are NOT in the customizer.
                      if ( ! is_customizer ) {
          Severity: Major
          Found in assets/js/frontend/auto-load-next-post.dev.js and 1 other location - About 1 hr to fix
          assets/js/frontend/auto-load-next-post.js on lines 266..275

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

          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 ( ( offset.top - scrollTop ) <= 200 && curr_url != this_url ) {
                      curr_url = this_url;
          
                      // Update the History ONLY if we are NOT in the customizer.
                      if ( ! is_customizer ) {
          Severity: Major
          Found in assets/js/frontend/auto-load-next-post.js and 1 other location - About 1 hr to fix
          assets/js/frontend/auto-load-next-post.dev.js on lines 311..320

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

          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

          Severity
          Category
          Status
          Source
          Language