felixarntz/post-types-definitely

View on GitHub

Showing 187 of 187 total issues

Method validate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

            if ( $status === true ) {

Severity: Major
Found in inc/WPPTD/Components/PostType.php - About 2 hrs to fix

    Function register_table_filter_query_vars has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            public function register_table_filter_query_vars( $vars ) {
                $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/PostTypeQueryHandler.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 register has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            public function register() {
                if ( $this->registered ) {
                    return;
                }
    
    
    Severity: Minor
    Found in inc/WPPTD/Components/Taxonomy.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

    File Taxonomy.php has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

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

      var readmeheader =    'Plugin Name:       ' + config.pluginName + '\n' +
                          'Plugin URI:        ' + config.pluginURI + '\n' +
                          'Author:            ' + config.author + '\n' +
                          'Author URI:        ' + config.authorURI + '\n' +
                          'Contributors:      ' + config.contributors + '\n' +
      Severity: Major
      Found in gulpfile.js and 1 other location - About 2 hrs to fix
      gulpfile.js on lines 45..50

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

      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

      var pluginheader =     'Plugin Name: ' + config.pluginName + '\n' +
                          'Plugin URI:  ' + config.pluginURI + '\n' +
                          'Description: ' + config.description + '\n' +
                          'Version:     ' + config.version + '\n' +
                          'Author:      ' + config.author + '\n' +
      Severity: Major
      Found in gulpfile.js and 1 other location - About 2 hrs to fix
      gulpfile.js on lines 58..63

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

      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 run_bulk_action has a Cognitive Complexity of 16 (exceeds 5 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 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 run_row_action has a Cognitive Complexity of 16 (exceeds 5 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 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 handle_bulk_actions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

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

              public static function validate_args( $args ) {
                  // handle row actions
                  if ( ! $args['show_ui'] || ! is_array( $args['row_actions'] ) ) {
                      $args['row_actions'] = array();
                  }
      Severity: Minor
      Found in inc/WPPTD/PostTypeActionHandler.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_args has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function validate_args( $args ) {
                  // handle row actions
                  if ( ! $args['show_ui'] || ! is_array( $args['row_actions'] ) ) {
                      $args['row_actions'] = array();
                  }
      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 add_post_types has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              protected function add_post_types( $post_types, $menu ) {
                  foreach ( $post_types as $post_type_slug => $post_type_args ) {
                      $post_type = $menu->add( new PostType( $post_type_slug, $post_type_args ) );
                      if ( is_wp_error( $post_type ) ) {
                          self::doing_it_wrong( __METHOD__, $post_type->get_error_message(), '0.5.0' );
      Severity: Minor
      Found in inc/WPPTD/App.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_row_actions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              public function filter_row_actions( $row_actions, $item ) {
                  $table_row_actions = $this->component->row_actions;
      
                  if ( ! call_user_func_array( 'current_user_can', $this->get_row_capability_args( $item ) ) ) {
                      return $row_actions;
      Severity: Minor
      Found in inc/WPPTD/ActionHandler.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_sort_by_meta_table_column has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              public function maybe_sort_by_meta_table_column( $query ) {
                  if ( is_object( $query ) ) {
                      $args_before = $query->query;
                      $args_after = $query->query_vars;
                  } else {
      Severity: Minor
      Found in inc/WPPTD/QueryHandler.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 14 (exceeds 5 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

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

              public function term_submit_metabox( $term ) {
                  $screen = get_current_screen();
      
                  $tax = $screen->taxonomy;
                  if ( empty( $tax ) ) {
      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 get_defaults has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              protected function get_defaults() {
                  $defaults = array(
                      'title'                => '',
                      'singular_title'       => '',
                      'title_gender'         => 'n',
      Severity: Minor
      Found in inc/WPPTD/Components/PostType.php - About 1 hr to fix

        Function render_meta_column_choice_filter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                protected function render_meta_column_choice_filter( $column_slug, $field, $active_filters ) {
                    echo '<select name="' . $column_slug . '" id="' . $column_slug . '" class="postform">';
                    echo '<option value="">' . esc_html( $field->title ) . ': ' . __( 'All', 'post-types-definitely' ) . '</option>';
                    foreach ( $field->options as $value => $label ) {
                        echo '<option value="' . esc_attr( $value ) . '"' . ( ( isset( $active_filters[ $column_slug ] ) && $active_filters[ $column_slug ] == $value ) ? ' selected="selected"' : '' ) . '>';
        Severity: Minor
        Found in inc/WPPTD/PostTypeTableHandler.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 wpptd_get_post_meta_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            function wpptd_get_post_meta_value( $id, $meta_key, $single = null, $formatted = false ) {
                $_meta_value = get_post_meta( $id, $meta_key, false );
        
                if ( doing_action( 'wpptd' ) || ! did_action( 'wpptd' ) ) {
                    if ( $single ) {
        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

        Severity
        Category
        Status
        Source
        Language