felixarntz/options-definitely

View on GitHub

Showing 22 of 27 total issues

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

        public function validate_options( $options ) {
            $options_validated = array();

            $options_old = get_option( $this->slug, array() );

Severity: Minor
Found in inc/WPOD/Components/Tab.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 validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        public function validate( $parent = null ) {
            $status = parent::validate( $parent );

            if ( $status === true ) {
                if ( is_array( $this->args['class'] ) ) {
Severity: Minor
Found in inc/WPOD/Components/Field.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 wpod_get_options has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    function wpod_get_options( $tab_slug, $formatted = false ) {
        $_options = get_option( $tab_slug, array() );

        if ( doing_action( 'wpod' ) || ! did_action( 'wpod' ) ) {
            return $_options;
Severity: Minor
Found in inc/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 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

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

        public function render() {
            $parent_screen = $this->get_parent();
            $parent_menu = $parent_screen->get_parent();

            if ( 'options-general.php' !== $parent_menu->menu_slug ) {
Severity: Minor
Found in inc/WPOD/Components/Tab.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 validate_options has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function validate_options( $options ) {
            $options_validated = array();

            $options_old = get_option( $this->slug, array() );

Severity: Minor
Found in inc/WPOD/Components/Tab.php - About 1 hr to fix

    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

      Function render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              public function render( $metabox = true ) {
                  // only display the title if the section is not displayed as a metabox
                  if ( null !== $metabox || false === $metabox ) {
                      echo '<h3>' . $this->args['title'] . '</h3>';
                  }
      Severity: Minor
      Found in inc/WPOD/Components/Section.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 validate_help_args has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function validate_help_args( $args, $key ) {
                  if( ! is_array( $args[ $key ] ) ) {
                      $args[ $key ] = array();
                  }
                  if ( ! isset( $args[ $key ]['tabs'] ) || ! is_array( $args[ $key ]['tabs'] ) ) {
      Severity: Minor
      Found in inc/WPOD/Utility.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

      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

        Function wpod_get_option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            function wpod_get_option( $tab_slug, $field_slug, $formatted = false ) {
                $_options = get_option( $tab_slug, array() );
        
                if ( doing_action( 'wpod' ) || ! did_action( 'wpod' ) ) {
                    if ( isset( $_options[ $field_slug ] ) ) {
        Severity: Minor
        Found in inc/functions.php - About 45 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 render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                public function render() {
                    $parent_menu = $this->get_parent();
        
                    echo '<div class="wrap">';
        
        
        Severity: Minor
        Found in inc/WPOD/Components/Screen.php - About 45 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 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

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

                  protected function add_menus( $menus ) {
                      foreach ( $menus as $menu_slug => $menu_args ) {
                          $menu = $this->add( new Menu( $menu_slug, $menu_args ) );
                          if ( is_wp_error( $menu ) ) {
                              self::doing_it_wrong( __METHOD__, $menu->get_error_message(), '0.5.0' );
          Severity: Minor
          Found in inc/WPOD/App.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 validate_option has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function validate_option( $option = null, $skip_required = false ) {
                      if ( $this->args['required'] && ! $skip_required ) {
                          if ( $option === null || $this->_field->is_empty( $option ) ) {
                              return new WPError( 'invalid_empty_value', __( 'No value was provided for the required field.', 'options-definitely' ) );
                          }
          Severity: Minor
          Found in inc/WPOD/Components/Field.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 enqueue_assets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function enqueue_assets() {
                      if ( 'draggable' == $this->args['mode'] ) {
                          wp_enqueue_script( 'common' );
                          wp_enqueue_script( 'wp-lists' );
                          wp_enqueue_script( 'postbox' );
          Severity: Minor
          Found in inc/WPOD/Components/Tab.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_tabs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  protected function add_tabs( $tabs, $screen ) {
                      foreach ( $tabs as $tab_slug => $tab_args ) {
                          $tab = $screen->add( new Tab( $tab_slug, $tab_args ) );
                          if ( is_wp_error( $tab ) ) {
                              self::doing_it_wrong( __METHOD__, $tab->get_error_message(), '0.5.0' );
          Severity: Minor
          Found in inc/WPOD/App.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_screens has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  protected function add_screens( $screens, $menu ) {
                      foreach ( $screens as $screen_slug => $screen_args ) {
                          $screen = $menu->add( new Screen( $screen_slug, $screen_args ) );
                          if ( is_wp_error( $screen ) ) {
                              self::doing_it_wrong( __METHOD__, $screen->get_error_message(), '0.5.0' );
          Severity: Minor
          Found in inc/WPOD/App.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_sections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  protected function add_sections( $sections, $tab ) {
                      foreach ( $sections as $section_slug => $section_args ) {
                          $section = $tab->add( new Section( $section_slug, $section_args ) );
                          if ( is_wp_error( $section ) ) {
                              self::doing_it_wrong( __METHOD__, $section->get_error_message(), '0.5.0' );
          Severity: Minor
          Found in inc/WPOD/App.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

          Severity
          Category
          Status
          Source
          Language