felixarntz/wpdlib

View on GitHub
inc/WPDLib/Components/Menu.php

Summary

Maintainability
C
1 day
Test Coverage

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

        protected function check_for_admin_page_func( $slug ) {
            if ( function_exists( 'add_' . $slug . '_page' ) ) {
                switch ( $slug ) {
                    case 'dashboard':
                        return 'index.php';
Severity: Minor
Found in inc/WPDLib/Components/Menu.php - About 1 hr to fix

    Function create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            public function create() {
                foreach ( $this->get_children() as $menu_item ) {
                    if ( is_callable( array( $menu_item, 'add_to_menu' ) ) ) {
                        if ( 'none' == $this->slug ) {
                            $this->add_non_menu_page( $menu_item );
    Severity: Minor
    Found in inc/WPDLib/Components/Menu.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 check_for_admin_page has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function check_for_admin_page( $slug, $admin_page_hooks ) {
                if ( isset( $admin_page_hooks[ $slug ] ) ) {
                    // check for the exact menu slug
                    return $slug;
                }
    Severity: Minor
    Found in inc/WPDLib/Components/Menu.php - About 55 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

    Function is_already_added has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            public function is_already_added( $screen_slug ) {
                global $admin_page_hooks;
    
                if ( $this->added ) {
                    return $this->added;
    Severity: Minor
    Found in inc/WPDLib/Components/Menu.php - About 55 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

    Function check_for_admin_page_func has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function check_for_admin_page_func( $slug ) {
                if ( function_exists( 'add_' . $slug . '_page' ) ) {
                    switch ( $slug ) {
                        case 'dashboard':
                            return 'index.php';
    Severity: Minor
    Found in inc/WPDLib/Components/Menu.php - About 35 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

    Function add_menu_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function add_menu_page( $menu_item ) {
                $status = false;
                if ( is_callable( array( $menu_item, 'add_to_menu' ) ) ) {
                    $status = $menu_item->add_to_menu( array(
                        'mode'            => 'menu',
    Severity: Minor
    Found in inc/WPDLib/Components/Menu.php - About 35 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

    Avoid too many return statements within this method.
    Open

                            return 'options-general.php';
    Severity: Major
    Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                              return 'edit-comments.php';
      Severity: Major
      Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                                return 'plugins.php';
        Severity: Major
        Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return false;
          Severity: Major
          Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                        return 'profile.php';
            Severity: Major
            Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                      return 'themes.php';
              Severity: Major
              Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return false;
                Severity: Major
                Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                              return 'users.php';
                  Severity: Major
                  Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                            return 'tools.php';
                    Severity: Major
                    Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                              return 'edit.php?post_type=page';
                      Severity: Major
                      Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status