felixarntz/options-definitely

View on GitHub
inc/WPOD/Admin.php

Summary

Maintainability
C
1 day
Test Coverage

Function get_current has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

        public function get_current( $type = '', $screen = null ) {
            if ( isset( $_GET['page'] ) ) {
                if ( null === $screen ) {
                    $screen = ComponentManager::get( '*.' . $_GET['page'], 'WPDLib\Components\Menu.WPOD\Components\Screen', true );
                }
Severity: Minor
Found in inc/WPOD/Admin.php - About 5 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 register_settings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        public function register_settings() {
            $tabs = ComponentManager::get( '*.*.*', 'WPDLib\Components\Menu.WPOD\Components\Screen' );
            foreach ( $tabs as $tab ) {
                /* Settings are registered globally in WordPress >= 4.7. */
                if ( version_compare( get_bloginfo( 'version' ), '4.7', '<' ) ) {
Severity: Minor
Found in inc/WPOD/Admin.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 get_current has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function get_current( $type = '', $screen = null ) {
            if ( isset( $_GET['page'] ) ) {
                if ( null === $screen ) {
                    $screen = ComponentManager::get( '*.' . $_GET['page'], 'WPDLib\Components\Menu.WPOD\Components\Screen', true );
                }
Severity: Minor
Found in inc/WPOD/Admin.php - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                                if ( $_GET['tab'] == $_tab->slug ) {
                                    $tab = $_tab;
                                    break;
                                }
    Severity: Major
    Found in inc/WPOD/Admin.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if ( 'tab' == $type ) {
                                  return $tab;
                              }
      Severity: Major
      Found in inc/WPOD/Admin.php - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status