wpsmith/Plugin

View on GitHub

Showing 15 of 15 total issues

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

              protected function get_delete_actions_content() {
                  $default_action = $this->get_uninstall_action();
      
                  $actions = array();
                  $content = sprintf(
      Severity: Minor
      Found in src/UninstallManager.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 delete_data_or_plugin has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function delete_data_or_plugin() {
                  if ( ! self::is_plugins_page() ) {
                      return;
                  }
      
      
      Severity: Minor
      Found in src/UninstallManager.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

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

                  public function add_action( string $tag, callable $function_to_add, $priority = 10, $accepted_args = 1, $args = array() ) {
          Severity: Minor
          Found in src/PluginBase.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 disable_plugin_updates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function disable_plugin_updates( $value ) {
                        if ( isset( $value ) && is_object( $value ) ) {
                            if ( isset( $value->response[ $this->plugin ] ) ) {
                                unset( $value->response[ $this->plugin ] );
                            }
            Severity: Minor
            Found in src/PreventUpdate.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 get_directory_default has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    protected function get_directory_default( $args ) {
                        if ( isset( $args['directory'] ) && '' !== $args['directory'] ) {
                            return $args['directory'];
                        } elseif ( isset( $args['file'] ) && '' !== $args['file'] ) {
                            return dirname( $args['file'] );
            Severity: Minor
            Found in src/PluginBase.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 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

            Severity
            Category
            Status
            Source
            Language