felixarntz/post-types-definitely

View on GitHub
inc/WPPTD/ActionHandler.php

Summary

Maintainability
D
2 days
Test Coverage

ActionHandler has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

    abstract class ActionHandler {
        /**
         * @since 0.6.1
         * @var WPDLib\Components\Base Holds the component this action handler should manage.
         */
Severity: Minor
Found in inc/WPPTD/ActionHandler.php - About 2 hrs to fix

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

            protected function handle_bulk_action( $sendback, $bulk_action, $item_ids ) {
                $bulk_actions = $this->component->bulk_actions;
                $component_plural_name = $this->component->title;
    
                $action_message = false;
    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

    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

      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

        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

        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

        There are no issues that match your filters.

        Category
        Status