wpsmith/Plugin

View on GitHub
src/ExtendPlugin.php

Summary

Maintainability
C
1 day
Test Coverage

Function plugin_action_links has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
            if ( ! $this->is_active() ) {
                if ( isset( $actions['deactivate'] ) ) {
                    $params = self::get_url_params( $actions['deactivate'] );
                    $params = wp_parse_args( $params, array( 's' => '', ) );
Severity: Minor
Found in src/ExtendPlugin.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

Function get_plugin_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        private function get_plugin_data( $attr = null, $plugin = null ) {
            // Default to dependency plugin
            if ( ! $plugin || 'dependency' === $plugin ) {
                $plugin      = $this->plugin;
                $plugin_path = trailingslashit( plugin_dir_path( dirname( $this->root_file ) ) ) . $this->plugin;
Severity: Minor
Found in src/ExtendPlugin.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 __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function __construct( $plugin, $root_file, $min_version = null, $text_domain = null, $custom_plugins_folder = '' ) {
            // Setup
            $this->plugin      = $plugin;
            $this->root_file   = $root_file;
            $this->min_version = $min_version ? $min_version : $this->min_version;
Severity: Minor
Found in src/ExtendPlugin.php - About 1 hr to fix

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

            private function set_message( $type ) {
                $dependency = $this->get_plugin_data( 'Name' ) ? $this->get_plugin_data( 'Name' ) : $this->plugin;
                switch ( $type ) {
                    case 'deactivate':
                        $current       = $this->get_plugin_data( 'Name', 'current' ) ? $this->get_plugin_data( 'Name', 'current' ) : plugin_basename( $this->root_file );
    Severity: Minor
    Found in src/ExtendPlugin.php - About 1 hr to fix

      Function is_active has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              public function is_active() {
                  $active = true;
      
                  // Check Plugin Active
                  if ( ! is_plugin_active( $this->plugin ) && ! isset( $this->mu[ $this->plugin ] ) ) {
      Severity: Minor
      Found in src/ExtendPlugin.php - About 55 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

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              public function __construct( $plugin, $root_file, $min_version = null, $text_domain = null, $custom_plugins_folder = '' ) {
      Severity: Minor
      Found in src/ExtendPlugin.php - About 35 mins to fix

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

                private function set_message( $type ) {
                    $dependency = $this->get_plugin_data( 'Name' ) ? $this->get_plugin_data( 'Name' ) : $this->plugin;
                    switch ( $type ) {
                        case 'deactivate':
                            $current       = $this->get_plugin_data( 'Name', 'current' ) ? $this->get_plugin_data( 'Name', 'current' ) : plugin_basename( $this->root_file );
        Severity: Minor
        Found in src/ExtendPlugin.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 maybe_deactivate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                public function maybe_deactivate( $old_value, $value ) {
                    if ( ! $this->is_active() ) {
                        self::deactivate_self( $this->root_file );
        
                        if ( defined( 'WP_CLI' ) && WP_CLI ) {
        Severity: Minor
        Found in src/ExtendPlugin.php - About 25 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 set_action_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                private function set_action_type() {
                    if ( isset( $_REQUEST['deactivate-multi'] ) && $_REQUEST['deactivate-multi'] ) {
                        $this->action = 'deactivate-multi';
                    } elseif ( isset( $_REQUEST['activate-multi'] ) && $_REQUEST['activate-multi'] ) {
                        $this->action = 'activate-multi';
        Severity: Minor
        Found in src/ExtendPlugin.php - About 25 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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                public function __construct( $plugin, $root_file, $min_version = null, $text_domain = null, $custom_plugins_folder = '' ) {
                    // Setup
                    $this->plugin      = $plugin;
                    $this->root_file   = $root_file;
                    $this->min_version = $min_version ? $min_version : $this->min_version;
        Severity: Minor
        Found in src/ExtendPlugin.php - About 25 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

        There are no issues that match your filters.

        Category
        Status