felixarntz/post-types-definitely

View on GitHub

Showing 187 of 187 total issues

Function validate has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

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

            if ( $status === true ) {

Severity: Minor
Found in inc/WPPTD/Components/PostType.php - About 6 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_args has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

        public static function validate_args( $args ) {
            // handle admin table columns
            if ( ! $args['show_ui'] || ! is_array( $args['table_columns'] ) ) {
                $args['table_columns'] = array();
            }
Severity: Minor
Found in inc/WPPTD/TaxonomyTableHandler.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

Method get_related_objects has 137 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
            // specify variables depending on the base mode
            switch ( $mode ) {
                case 'post':
                    $get_func = 'get_post';
Severity: Major
Found in inc/WPPTD/Utility.php - About 5 hrs to fix

    File PostType.php has 388 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * WPPTD\Components\PostType class
     *
     * @package WPPTD
    Severity: Minor
    Found in inc/WPPTD/Components/PostType.php - About 5 hrs to fix

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

                  if ( ! call_user_func_array( 'current_user_can', $this->get_bulk_capability_args() ) ) {
                      $action_message = sprintf( __( 'The %s were not updated because of missing privileges.', 'post-types-definitely' ), $component_plural_name );
                      $error = true;
                  } elseif ( empty( $bulk_actions[ $bulk_action ]['callback'] ) || ! is_callable( $bulk_actions[ $bulk_action ]['callback'] ) ) {
                      $action_message = sprintf( __( 'The %s were not updated since an internal error occurred.', 'post-types-definitely' ), $component_plural_name );
      Severity: Major
      Found in inc/WPPTD/ActionHandler.php and 1 other location - About 5 hrs to fix
      inc/WPPTD/ActionHandler.php on lines 395..407

      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 189.

      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 3 locations. Consider refactoring.
      Open

              private static function get_messages_feminine( $plural_name, $singular_name ) {
                  return array(
                       0 => '',
                       1 => sprintf( _x( '%s added.', 'term message: argument is the singular taxonomy label (feminine)', 'post-types-definitely' ), $singular_name ),
                       2 => sprintf( _x( '%s deleted.', 'term message: argument is the singular taxonomy label (feminine)', 'post-types-definitely' ), $singular_name ),
      Severity: Major
      Found in inc/WPPTD/TaxonomyLabelGenerator.php and 2 other locations - About 5 hrs to fix
      inc/WPPTD/TaxonomyLabelGenerator.php on lines 169..179
      inc/WPPTD/TaxonomyLabelGenerator.php on lines 209..219

      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 189.

      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 3 locations. Consider refactoring.
      Open

              private static function get_messages_masculine( $plural_name, $singular_name ) {
                  return array(
                       0 => '',
                       1 => sprintf( _x( '%s added.', 'term message: argument is the singular taxonomy label (masculine)', 'post-types-definitely' ), $singular_name ),
                       2 => sprintf( _x( '%s deleted.', 'term message: argument is the singular taxonomy label (masculine)', 'post-types-definitely' ), $singular_name ),
      Severity: Major
      Found in inc/WPPTD/TaxonomyLabelGenerator.php and 2 other locations - About 5 hrs to fix
      inc/WPPTD/TaxonomyLabelGenerator.php on lines 189..199
      inc/WPPTD/TaxonomyLabelGenerator.php on lines 209..219

      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 189.

      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 3 locations. Consider refactoring.
      Open

              private static function get_messages_neuter( $plural_name, $singular_name ) {
                  return array(
                       0 => '',
                       1 => sprintf( _x( '%s added.', 'term message: argument is the singular taxonomy label (neuter)', 'post-types-definitely' ), $singular_name ),
                       2 => sprintf( _x( '%s deleted.', 'term message: argument is the singular taxonomy label (neuter)', 'post-types-definitely' ), $singular_name ),
      Severity: Major
      Found in inc/WPPTD/TaxonomyLabelGenerator.php and 2 other locations - About 5 hrs to fix
      inc/WPPTD/TaxonomyLabelGenerator.php on lines 169..179
      inc/WPPTD/TaxonomyLabelGenerator.php on lines 189..199

      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 189.

      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

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

                  if ( ! call_user_func_array( 'current_user_can', $this->get_bulk_capability_args() ) ) {
                      $action_message = sprintf( __( 'The %s were not updated because of missing privileges.', 'post-types-definitely' ), $component_plural_name );
                      $error = true;
                  } elseif ( empty( $bulk_actions[ $bulk_action ]['callback'] ) || ! is_callable( $bulk_actions[ $bulk_action ]['callback'] ) ) {
                      $action_message = sprintf( __( 'The %s were not updated since an internal error occurred.', 'post-types-definitely' ), $component_plural_name );
      Severity: Major
      Found in inc/WPPTD/ActionHandler.php and 1 other location - About 5 hrs to fix
      inc/WPPTD/ActionHandler.php on lines 441..453

      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 189.

      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

      Function validate_labels has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function validate_labels( $args, $key, $mode ) {
                  if ( false === $args[ $key ] ) {
                      $args[ $key ] = array();
                      return $args;
                  }
      Severity: Minor
      Found in inc/WPPTD/Utility.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

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

                  foreach ( $this->get_children( 'WPPTD\Components\TermMetabox' ) as $metabox ) {
                      foreach ( $metabox->get_children() as $field ) {
                          $meta_value_old = wpptd_get_term_meta_value( $term_id, $field->slug );
                          if ( $meta_value_old === null ) {
                              $meta_value_old = $field->default;
      Severity: Major
      Found in inc/WPPTD/Components/Taxonomy.php and 1 other location - About 5 hrs to fix
      inc/WPPTD/Components/PostType.php on lines 617..639

      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 184.

      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

                  foreach ( $this->get_children( 'WPPTD\Components\Metabox' ) as $metabox ) {
                      foreach ( $metabox->get_children() as $field ) {
                          $meta_value_old = wpptd_get_post_meta_value( $post_id, $field->slug );
                          if ( $meta_value_old === null ) {
                              $meta_value_old = $field->default;
      Severity: Major
      Found in inc/WPPTD/Components/PostType.php and 1 other location - About 5 hrs to fix
      inc/WPPTD/Components/Taxonomy.php on lines 446..468

      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 184.

      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

      Admin has 37 functions (exceeds 20 allowed). Consider refactoring.
      Open

          class Admin {
      
              /**
               * @since 0.5.0
               * @var WPPTD\Admin|null Holds the instance of this class.
      Severity: Minor
      Found in inc/WPPTD/Admin.php - About 4 hrs to fix

        Function maybe_filter_by_table_columns has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

                public function maybe_filter_by_table_columns( $wp_query ) {
                    $table_columns = $this->component->table_columns;
        
                    $tax_query = array();
                    $meta_query = array();
        Severity: Minor
        Found in inc/WPPTD/PostTypeQueryHandler.php - About 4 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

        Identical blocks of code found in 2 locations. 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: Major
        Found in inc/WPPTD/PostTypeLabelGenerator.php and 1 other location - About 4 hrs to fix
        inc/WPPTD/TaxonomyLabelGenerator.php on lines 35..51

        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 172.

        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

        Identical blocks of code found in 2 locations. 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: Major
        Found in inc/WPPTD/TaxonomyLabelGenerator.php and 1 other location - About 4 hrs to fix
        inc/WPPTD/PostTypeLabelGenerator.php on lines 35..51

        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 172.

        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

        Function get_table_taxonomies has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

                public function get_table_taxonomies( $taxonomies ) {
                    $table_columns = $this->component->table_columns;
        
                    foreach ( $table_columns as $column_slug => $column_args ) {
                        if ( $column_args && ! empty( $column_args['taxonomy_slug'] ) && is_object_in_taxonomy( $this->component->slug, $column_args['taxonomy_slug'] ) ) {
        Severity: Minor
        Found in inc/WPPTD/PostTypeTableHandler.php - About 4 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 wpptd_get_term_meta_values has a Cognitive Complexity of 28 (exceeds 5 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 4 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

        File Utility.php has 333 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * @package WPPTD
         * @version 0.6.4
         * @author Felix Arntz <felix-arntz@leaves-and-love.net>
        Severity: Minor
        Found in inc/WPPTD/Utility.php - About 4 hrs to fix

          Function render_table_column_filters has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function render_table_column_filters() {
                      $table_columns = $this->component->table_columns;
          
                      foreach ( $table_columns as $column_slug => $column_args ) {
                          if ( is_array( $column_args ) && $column_args['filterable'] ) {
          Severity: Minor
          Found in inc/WPPTD/PostTypeTableHandler.php - About 3 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

          Severity
          Category
          Status
          Source
          Language