felixarntz/post-types-definitely

View on GitHub

Showing 187 of 187 total issues

Method run_bulk_action has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function run_bulk_action( $bulk_action, $item_ids ) {
            $bulk_actions = $this->component->bulk_actions;
            $component_plural_name = $this->component->title;

            check_admin_referer( $this->get_bulk_nonce_name() );
Severity: Minor
Found in inc/WPPTD/ActionHandler.php - About 1 hr to fix

    Method run_row_action has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            protected function run_row_action( $row_action, $item_id ) {
                $row_actions = $this->component->row_actions;
                $component_singular_title = $this->component->singular_title;
    
                check_admin_referer( $this->get_row_nonce_name( $row_action, $item_id ) );
    Severity: Minor
    Found in inc/WPPTD/ActionHandler.php - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              protected function add_settings_message( $errors, $term_id ) {
                  if ( count( $errors ) > 0 ) {
                      $error_text = __( 'Some errors occurred while trying to save the following term meta:', 'post-types-definitely' );
                      foreach ( $errors as $field_slug => $error ) {
                          $error_text .= '<br/><em>' . $field_slug . '</em>: ' . $error->get_error_message();
      Severity: Major
      Found in inc/WPPTD/Components/Taxonomy.php and 1 other location - About 1 hr to fix
      inc/WPPTD/Components/PostType.php on lines 746..755

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 105.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              protected function add_settings_message( $errors, $post_id ) {
                  if ( count( $errors ) > 0 ) {
                      $error_text = __( 'Some errors occurred while trying to save the following post meta:', 'post-types-definitely' );
                      foreach ( $errors as $field_slug => $error ) {
                          $error_text .= '<br/><em>' . $field_slug . '</em>: ' . $error->get_error_message();
      Severity: Major
      Found in inc/WPPTD/Components/PostType.php and 1 other location - About 1 hr to fix
      inc/WPPTD/Components/Taxonomy.php on lines 534..543

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 105.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method validate_meta_values has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              protected function validate_meta_values( $meta_values, $term_id ) {
                  $meta_values_validated = array();
      
                  $meta_values_old = array();
      
      
      Severity: Minor
      Found in inc/WPPTD/Components/Taxonomy.php - About 1 hr to fix

        Similar blocks of code found in 2 locations. 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: Major
        Found in inc/WPPTD/App.php and 1 other location - About 1 hr to fix
        inc/WPPTD/App.php on lines 279..288

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 104.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. 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: Major
        Found in inc/WPPTD/App.php and 1 other location - About 1 hr to fix
        inc/WPPTD/App.php on lines 362..371

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 104.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method add_taxonomies has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                protected function add_taxonomies( $taxonomies, $post_type ) {
                    foreach ( $taxonomies as $taxonomy_slug => $taxonomy_args ) {
                        if ( is_array( $taxonomy_args ) ) {
                            $taxonomy = $post_type->add( new Taxonomy( $taxonomy_slug, $taxonomy_args ) );
                            if ( is_wp_error( $taxonomy ) ) {
        Severity: Minor
        Found in inc/WPPTD/App.php - About 1 hr to fix

          Method wpptd_get_term_meta_values has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function wpptd_get_term_meta_values( $id, $single = null, $formatted = false ) {
                  if ( ! wpptd_supports_termmeta() ) {
                      return array();
                  }
          
          
          Severity: Minor
          Found in inc/functions.php - About 1 hr to fix

            Method register has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function register() {
                        if ( $this->registered ) {
                            return;
                        }
            
            
            Severity: Minor
            Found in inc/WPPTD/Components/Taxonomy.php - About 1 hr to fix

              Method get_labels_masculine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      private static function get_labels_masculine( $plural_name, $singular_name ) {
                          return array(
                              'name'                  => $plural_name,
                              'singular_name'         => $singular_name,
                              'menu_name'             => $plural_name,
              Severity: Minor
              Found in inc/WPPTD/PostTypeLabelGenerator.php - About 1 hr to fix

                Method enqueue_assets has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        public function enqueue_assets() {
                            $screen = get_current_screen();
                
                            if ( isset( $screen->taxonomy ) && $screen->taxonomy ) {
                                $taxonomy = ComponentManager::get( '*.*.' . $screen->taxonomy, 'WPDLib\Components\Menu.WPPTD\Components\PostType.WPPTD\Components\Taxonomy', true );
                Severity: Minor
                Found in inc/WPPTD/Admin.php - About 1 hr to fix

                  Method get_labels_feminine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          private static function get_labels_feminine( $plural_name, $singular_name ) {
                              return array(
                                  'name'                  => $plural_name,
                                  'singular_name'         => $singular_name,
                                  'menu_name'             => $plural_name,
                  Severity: Minor
                  Found in inc/WPPTD/PostTypeLabelGenerator.php - About 1 hr to fix

                    Method get_labels_neuter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            private static function get_labels_neuter( $plural_name, $singular_name ) {
                                return array(
                                    'name'                  => $plural_name,
                                    'singular_name'         => $singular_name,
                                    'menu_name'             => $plural_name,
                    Severity: Minor
                    Found in inc/WPPTD/PostTypeLabelGenerator.php - About 1 hr to fix

                      Method maybe_register_related_objects_field has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              public static function maybe_register_related_objects_field( $object, $args, $component, $component_parent ) {
                                  if ( ! isset( $args['options'] ) || ! is_array( $args['options'] ) || 1 !== count( $args['options'] ) ) {
                                      return;
                                  }
                      
                      
                      Severity: Minor
                      Found in inc/WPPTD/Utility.php - About 1 hr to fix

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

                                public function filter_table_columns( $columns ) {
                                    $table_columns = $this->component->table_columns;
                        
                                    foreach ( $table_columns as $column_slug => $column_args ) {
                                        $column_title = $this->filter_table_column( $column_slug, $column_args );
                        Severity: Minor
                        Found in inc/WPPTD/TableHandler.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 filter_table_sortable_columns has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                                public function filter_table_sortable_columns( $columns ) {
                                    $table_columns = $this->component->table_columns;
                        
                                    foreach ( $table_columns as $column_slug => $column_args ) {
                                        $column_sort = $this->filter_table_sortable_column( $column_slug, $column_args );
                        Severity: Minor
                        Found in inc/WPPTD/TableHandler.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 maybe_hack_action_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                                public function maybe_hack_action_message( $bulk_messages, $bulk_counts = array() ) {
                                    $request_data = $_REQUEST;
                        
                                    if ( isset( $request_data['updated'] ) && 0 < (int) $request_data['updated'] && isset( $request_data['message'] ) && 1 === (int) $request_data['message'] ) {
                                        $transient_name = $this->get_message_transient_name();
                        Severity: Minor
                        Found in inc/WPPTD/TaxonomyActionHandler.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 get_bulk_post_updated_messages has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                                public function get_bulk_post_updated_messages( $messages, $counts ) {
                                    $post_types = ComponentManager::get( '*.*', 'WPDLib\Components\Menu.WPPTD\Components\PostType' );
                                    foreach ( $post_types as $post_type ) {
                                        if ( ! in_array( $post_type->slug, array( 'post', 'page', 'attachment' ) ) ) {
                                            $post_type_messages = $post_type->get_bulk_updated_messages( $counts );
                        Severity: Minor
                        Found in inc/WPPTD/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 render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                public function render( $term ) {
                                    $parent_taxonomy = $this->get_parent();
                        
                                    if ( 'side' == $this->args['context'] ) {
                                        echo '<div class="wpdlib-narrow">';
                        Severity: Minor
                        Found in inc/WPPTD/Components/TermMetabox.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language