deep-web-solutions/wordpress-framework-utilities

View on GitHub

Showing 26 of 57 total issues

Function status_to_boolean has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function status_to_boolean( $are_deps_fulfilled, bool $include_optional = true ): bool {
        if ( \is_array( \reset( $are_deps_fulfilled ) ) ) { // MultiCheckerHandler
            foreach ( $are_deps_fulfilled as $deps_status ) {
                if ( false === $include_optional ) {
                    $optional_keys = Arrays::search_keys( $deps_status, true, array( self::class, 'is_optional_checker' ) );
Severity: Minor
Found in src/includes/Dependencies/Helpers/DependenciesServiceHelpers.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 get_missing_dependencies has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_missing_dependencies(): array {
        $missing = array();

        if ( \function_exists( 'ini_get' ) ) {
            foreach ( $this->get_dependencies() as $dependency ) {

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

    protected function output_local(): ?OutputFailureException {
        foreach ( $this->get_store()->get_all() as $admin_notices_store ) {
            if ( $admin_notices_store instanceof StoreInterface ) {
                foreach ( $this->get_notices( $admin_notices_store->get_id() ) as $notice ) {
                    $result = $this->output_notice( $notice, $admin_notices_store );
Severity: Minor
Found in src/includes/AdminNotices/AbstractAdminNoticesHandler.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 get_plugin_name has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function get_plugin_name( string $plugin, array $plugin_config ): string {
        if ( $this->is_plugin_active( $plugin, $plugin_config ) ) {
            if ( isset( $plugin_config['name_getter'] ) && \is_callable( $plugin_config['name_getter'] ) ) {
                $plugin_name = Strings::maybe_cast( \call_user_func( $plugin_config['name_getter'] ), '' );
            } else {
Severity: Minor
Found in src/includes/Dependencies/Checkers/WPPluginsChecker.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 output_dismiss_js has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function output_dismiss_js(): void {
        if ( false === $this->has_output ) {
            return;
        }

Severity: Minor
Found in src/includes/AdminNotices/Handlers/DismissibleNoticesHandler.php - About 1 hr to fix

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

        public function setup_active_state_dependencies_admin_notices(): ?SetupFailureException {
            $deps_handler = $this->get_dependencies_handler( DependencyContextsEnum::ACTIVE_STATE );
            if ( \is_null( $deps_handler ) ) {
                throw new NotImplementedException( 'Dependencies admin notices scenario not supported' );
            }

      Method get_admin_notice_handle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_admin_notice_handle( string $name = '', $extra = array(), string $root = 'dws-framework-utilities' ): string {
              if ( $this instanceof PluginComponentInterface ) {
                  $root = ( 'dws-framework-utilities' === $root ) ? '' : $root;
                  $root = \join( '_', array( $this->get_plugin()->get_plugin_slug(), $root ?: $this->get_name() ) );
              } elseif ( 'dws-framework-utilities' === $root ) {
      Severity: Minor
      Found in src/includes/AdminNotices/Helpers/AdminNoticesHelpersTrait.php - About 1 hr to fix

        Method get_missing_dependencies has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_missing_dependencies(): array {
                $missing = array();
        
                if ( \function_exists( 'ini_get' ) ) {
                    foreach ( $this->get_dependencies() as $dependency ) {

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

              public function setup_active_state_dependencies_admin_notices(): ?SetupFailureException {
                  $deps_handler = $this->get_dependencies_handler( DependencyContextsEnum::ACTIVE_STATE );
                  if ( \is_null( $deps_handler ) ) {
                      throw new NotImplementedException( 'Dependencies admin notices scenario not supported' );
                  }

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

              protected function initialize_dependencies_handlers(): ?InitializationFailureException {
                  if ( $this instanceof DependenciesServiceAwareInterface ) {
                      $service = $this->get_dependencies_service();
                  } elseif ( $this instanceof ContainerAwareInterface ) {
                      $service = $this->get_container()->get( DependenciesService::class );

          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 add_filter has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function add_filter( string $hook, ?object $component, string $callback, int $priority = 10, int $accepted_args = 1 );
          Severity: Minor
          Found in src/includes/Hooks/HooksAdapterInterface.php - About 35 mins to fix

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

                public function validate_allowed_value( $value, string $default_key, string $options_key, string $validation_type, string $handler_id = 'settings' ) {
            Severity: Minor
            Found in src/includes/Validation/ValidationService.php - About 35 mins to fix

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

                  public function add_filter( string $hook, ?object $component, string $callback, int $priority = 10, int $accepted_args = 1 ): void {
              Severity: Minor
              Found in src/includes/Hooks/Handlers/DirectHooksHandler.php - About 35 mins to fix

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

                    public function add_action( string $hook, ?object $component, string $callback, int $priority = 10, int $accepted_args = 1 );
                Severity: Minor
                Found in src/includes/Hooks/HooksAdapterInterface.php - About 35 mins to fix

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

                      protected function validate_allowed_value( $value, string $default_key, string $options_key, string $validation_type, string $handler_id = 'settings' ) {
                  Severity: Minor
                  Found in src/includes/Validation/ValidationServiceAwareTrait.php - About 35 mins to fix

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

                        public function add_action( string $hook, ?object $component, string $callback, int $priority = 10, int $accepted_args = 1 ): void {
                    Severity: Minor
                    Found in src/includes/Hooks/Handlers/DirectHooksHandler.php - About 35 mins to fix

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

                          public function remove_filter( string $hook, ?object $component, string $callback, int $priority = 10, string $handler_id = 'buffered' ): void {
                      Severity: Minor
                      Found in src/includes/Hooks/HooksService.php - About 35 mins to fix

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

                            public function remove_action( string $hook, ?object $component, string $callback, int $priority = 10, string $handler_id = 'buffered' ): void {
                        Severity: Minor
                        Found in src/includes/Hooks/HooksService.php - About 35 mins to fix

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

                              public function validate_allowed_value( $value, string $default_key, string $options_key, string $validation_type, string $handler_id );
                          Severity: Minor
                          Found in src/includes/Validation/ValidationServiceInterface.php - About 35 mins to fix

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

                                public function __construct( PluginInterface $plugin, LoggingService $logging_service, HooksService $hooks_service, array $stores = array(), array $handlers = array() ) {
                            Severity: Minor
                            Found in src/includes/AdminNotices/AdminNoticesService.php - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language