felixarntz/post-types-definitely

View on GitHub

Showing 150 of 187 total issues

Avoid deeply nested control flow statements.
Open

                        if ( isset( $labels['insert_into_item'] ) && $labels['insert_into_item'] ) {
                            $strings['insertIntoPost'] = $labels['insert_into_item'];
                        }
Severity: Major
Found in inc/WPPTD/Admin.php - About 45 mins to fix

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

            protected function filter_table_sortable_column( $slug, $args ) {
                if ( ! is_array( $args ) ) {
                    return false;
                }
    
    
    Severity: Minor
    Found in inc/WPPTD/PostTypeTableHandler.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 handle_term_row_actions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            public function handle_term_row_actions() {
                global $taxnow;
    
                // do not run this on a terms list
                if ( ! isset( $_GET['tag_ID'] ) ) {
    Severity: Minor
    Found in inc/WPPTD/Admin.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 ( 'category' === $taxonomy_slug ) {
                                    $column_key = 'categories';
                                } elseif ( 'post_tag' === $taxonomy_slug || 'tag' === $taxonomy_slug ) {
                                    $column_key = 'tags';
                                }
    Severity: Major
    Found in inc/WPPTD/PostTypeTableHandler.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if ( wpptd_supports_termmeta() ) {
                                  $taxonomy->enqueue_assets();
                              }
      Severity: Major
      Found in inc/WPPTD/Admin.php - About 45 mins to fix

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

                public function initialize_term_ui() {
                    $screen = get_current_screen();
                    if ( ! isset( $_REQUEST['tag_ID'] ) ) {
                        return;
                    }
        Severity: Minor
        Found in inc/WPPTD/Admin.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 ( false !== ( $key = array_search( $column_key, $taxonomies ) ) ) {
                                        unset( $taxonomies[ $key ] );
                                    }
        Severity: Major
        Found in inc/WPPTD/PostTypeTableHandler.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if ( $taxonomy ) {
                                          $this->render_taxonomy_column_filter( $column_slug, $taxonomy );
                                      }
          Severity: Major
          Found in inc/WPPTD/PostTypeTableHandler.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if ( isset( $labels['uploaded_to_this_item'] ) && $labels['uploaded_to_this_item'] ) {
                                        $strings['uploadedToThisPost'] = $labels['uploaded_to_this_item'];
                                    }
            Severity: Major
            Found in inc/WPPTD/Admin.php - About 45 mins to fix

              Method get_related_objects has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
              Severity: Minor
              Found in inc/WPPTD/Utility.php - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                if ( ! class_exists( 'WPPTD\PostTypeTableHandler' ) ) {
                    /**
                     * This class handles the post list table for a post type registered with WPPTD.
                     *
                     * @internal
                Severity: Major
                Found in inc/WPPTD/PostTypeTableHandler.php - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                                      if ( ( 0 <= version_compare( get_bloginfo( 'version' ), '4.5' ) && 'term' === $screen->base ) || ( 0 > version_compare( get_bloginfo( 'version' ), '4.5' ) && 'edit-tags' === $screen->base && isset( $_GET['tag_ID'] ) && is_numeric( $_GET['tag_ID'] ) ) ) {
                                          if ( wpptd_supports_termmeta() ) {
                                              $taxonomy->enqueue_assets();
                                          }
                  
                  
                  Severity: Major
                  Found in inc/WPPTD/Admin.php - About 40 mins to fix

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

                            public function add_term_or_term_list_help() {
                                global $taxnow;
                    
                                $taxonomy = ComponentManager::get( '*.*.' . $taxnow, 'WPDLib\Components\Menu.WPPTD\Components\PostType.WPPTD\Components\Taxonomy', true );
                                if ( $taxonomy ) {
                    Severity: Minor
                    Found in inc/WPPTD/Admin.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 filter_by_meta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                            protected function filter_by_meta( $value, $column_slug, $meta_key ) {
                                $meta_value = stripslashes( $value);
                                if ( $meta_value ) {
                                    $this->active_filters[ $column_slug ] = $meta_value;
                                    if ( 'bool:true' === $meta_value ) {
                    Severity: Minor
                    Found in inc/WPPTD/PostTypeQueryHandler.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_metaboxes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                            protected function add_metaboxes( $metaboxes, $post_type ) {
                                foreach ( $metaboxes as $metabox_slug => $metabox_args ) {
                                    $metabox = $post_type->add( new Metabox( $metabox_slug, $metabox_args ) );
                                    if ( is_wp_error( $metabox ) ) {
                                        self::doing_it_wrong( __METHOD__, $metabox->get_error_message(), '0.5.0' );
                    Severity: Minor
                    Found in inc/WPPTD/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 generate_labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                            public static function generate_labels( $plural_name, $singular_name, $type = 'labels', $gender = 'neuter' ) {
                                $gender_map = array( 'm' => 'masculine', 'f' => 'feminine', 'n' => 'neuter' );
                                if ( isset( $gender_map[ $gender ] ) ) {
                                    $gender = $gender_map[ $gender ];
                                }
                    Severity: Minor
                    Found in inc/WPPTD/TaxonomyLabelGenerator.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 generate_labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                            public static function generate_labels( $plural_name, $singular_name, $type = 'labels', $gender = 'neuter' ) {
                                $gender_map = array( 'm' => 'masculine', 'f' => 'feminine', 'n' => 'neuter' );
                                if ( isset( $gender_map[ $gender ] ) ) {
                                    $gender = $gender_map[ $gender ];
                                }
                    Severity: Minor
                    Found in inc/WPPTD/PostTypeLabelGenerator.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_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/WPPTD/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_meta_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                            public function validate_meta_value( $meta_value = null, $skip_required = false ) {
                                if ( $this->args['required'] && ! $skip_required ) {
                                    if ( $meta_value === null || $this->_field->is_empty( $meta_value ) ) {
                                        return new WPError( 'invalid_empty_value', __( 'No value was provided for the required field.', 'post-types-definitely' ) );
                                    }
                    Severity: Minor
                    Found in inc/WPPTD/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

                    Avoid too many return statements within this method.
                    Open

                                return true;
                    Severity: Major
                    Found in inc/WPPTD/Components/Taxonomy.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language