seb86/Auto-Load-Next-Post

View on GitHub
includes/customizer/class-alnp-customizer.php

Summary

Maintainability
D
2 days
Test Coverage

File class-alnp-customizer.php has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Auto Load Next Post: Theme Customizer
 *
 * @since    1.5.0
Severity: Minor
Found in includes/customizer/class-alnp-customizer.php - About 4 hrs to fix

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

        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

          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

          Avoid too many return statements within this method.
          Open

                      return true;
          Severity: Major
          Found in includes/customizer/class-alnp-customizer.php - About 30 mins to fix

            Function is_page_alnp_ready has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function is_page_alnp_ready() {
                        if ( is_front_page() && is_home() ) {
                            return false;
                        } elseif ( is_front_page() ) {
                            return false;
            Severity: Minor
            Found in includes/customizer/class-alnp-customizer.php - About 25 mins 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

            There are no issues that match your filters.

            Category
            Status