deep-web-solutions/wordpress-framework-foundations

View on GitHub

Showing 17 of 29 total issues

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

    public function get_hook_tag( string $name, $extra = array(), string $root = 'dws_framework_foundations' ): string {
        if ( $this instanceof PluginComponentInterface ) {
            $root = ( 'dws_framework_foundations' === $root ) ? '' : $root;
            $root = \join( '/', array( $this->get_plugin()->get_plugin_safe_slug(), $root ?: $this->get_safe_name() ) );
        } elseif ( 'dws_framework_foundations' === $root ) {
Severity: Major
Found in src/includes/Helpers/HooksHelpersTrait.php and 1 other location - About 2 hrs to fix
src/includes/Helpers/AssetsHelpersTrait.php on lines 31..44

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

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

    public function get_asset_handle( string $name = '', $extra = array(), string $root = 'dws-framework-foundations' ): string {
        if ( $this instanceof PluginComponentInterface ) {
            $root = ( 'dws-framework-foundations' === $root ) ? '' : $root;
            $root = \join( '_', array( $this->get_plugin()->get_plugin_slug(), $root ?: $this->get_name() ) );
        } elseif ( 'dws-framework-foundations' === $root ) {
Severity: Major
Found in src/includes/Helpers/AssetsHelpersTrait.php and 1 other location - About 2 hrs to fix
src/includes/Helpers/HooksHelpersTrait.php on lines 31..44

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

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

    protected function add_container_children(): ?InitializationFailureException {
        $init_result = null;

        if ( $this instanceof ParentInterface ) {
            $di_container = null;
Severity: Minor
Found in src/includes/Hierarchy/Actions/AddContainerChildrenTrait.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_execute_extension_traits has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function maybe_execute_extension_traits( string $extension_trait, $success_return = null, string $prefix = '' ) {
        if ( Objects::has_trait_deep( $extension_trait, $this ) ) {
            foreach ( Objects::class_uses_deep_list( $this ) as $trait ) {
                if ( ! isset( Objects::trait_uses_deep_list( $trait )[ $extension_trait ] ) ) {
                    continue;
Severity: Minor
Found in src/includes/Helpers/ActionExtensionHelpersTrait.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 integrate_maybe_setup_children has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function integrate_maybe_setup_children(): ?SetupFailureException {
        $setup_result = null;

        if ( $this instanceof ParentInterface ) {
            $children = $this->get_children();
Severity: Minor
Found in src/includes/Hierarchy/Actions/MaybeSetupChildrenTrait.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 integrate_setup_children has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function integrate_setup_children(): ?SetupFailureException {
        $setup_result = null;

        if ( $this instanceof ParentInterface ) {
            $children = $this->get_children();
Severity: Minor
Found in src/includes/Hierarchy/Actions/SetupChildrenTrait.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 integrate_initialize_children has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function integrate_initialize_children(): ?InitializationFailureException {
        $init_result = null;

        if ( $this instanceof ParentInterface ) {
            $children = $this->get_children();
Severity: Minor
Found in src/includes/Hierarchy/Actions/InitializeChildrenTrait.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 reset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function reset(): ?ResetFailureException {
        if ( \is_null( $this->is_reset ) ) {
            if ( ! \is_null( $result = $this->maybe_execute_local_trait( ResetLocalTrait::class, 'reset' ) ) ) { // phpcs:ignore
                $this->is_reset     = false;
                $this->reset_result = $result;
Severity: Minor
Found in src/includes/Actions/Resettable/ResettableTrait.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

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

    public function run(): ?RunFailureException {
        if ( \is_null( $this->is_run ) ) {
            if ( ! \is_null( $result = $this->maybe_execute_local_trait( RunLocalTrait::class, 'run' ) ) ) { // phpcs:ignore
                $this->is_run     = false;
                $this->run_result = $result;
Severity: Minor
Found in src/includes/Actions/Runnable/RunnableTrait.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

Function reset_handlers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function reset_handlers(): ?ResetFailureException {
        $reset_result = null;

        if ( $this instanceof HandlerAwareInterface || $this instanceof MultiHandlerAwareInterface ) {
            $handlers = ( $this instanceof HandlerAwareInterface ) ? array( $this->get_handler() ) : $this->get_handlers();
Severity: Minor
Found in src/includes/Services/Actions/ResetHandlersTrait.php - About 45 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 run_handlers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function run_handlers(): ?RunFailureException {
        $run_result = null;

        if ( $this instanceof HandlerAwareInterface || $this instanceof MultiHandlerAwareInterface ) {
            $handlers = ( $this instanceof HandlerAwareInterface ) ? array( $this->get_handler() ) : $this->get_handlers();
Severity: Minor
Found in src/includes/Services/Actions/RunHandlersTrait.php - About 45 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 output_handlers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function output_handlers(): ?OutputFailureException {
        $output_result = null;

        if ( $this instanceof HandlerAwareInterface || $this instanceof MultiHandlerAwareInterface ) {
            $handlers = ( $this instanceof HandlerAwareInterface ) ? array( $this->get_handler() ) : $this->get_handlers();
Severity: Minor
Found in src/includes/Services/Actions/OutputHandlersTrait.php - About 45 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

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

    protected function should_setup_child( SetupableInterface $child ): bool {
        $should_setup = true;

        if ( $child instanceof DisableableInterface ) {
            $should_setup = ( ! $child->is_disabled() || Objects::has_trait_deep( SetupableDisabledTrait::class, $child ) );
Severity: Minor
Found in src/includes/Hierarchy/Actions/MaybeSetupChildrenTrait.php and 1 other location - About 40 mins to fix
src/includes/Actions/Initializable/Integrations/MaybeSetupOnInitializationTrait.php on lines 53..65

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

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

    protected function should_setup(): bool {
        $should_setup = true;

        if ( $this instanceof DisableableInterface ) {
            $should_setup = ( ! $this->is_disabled() || Objects::has_trait_deep( SetupableDisabledTrait::class, $this ) );
src/includes/Hierarchy/Actions/MaybeSetupChildrenTrait.php on lines 70..82

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

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

    public function initialize(): ?InitializationFailureException {
        if ( \is_null( $this->is_initialized ) ) {
            if ( ! \is_null( $result = $this->maybe_execute_local_trait( InitializeLocalTrait::class, 'initialize' ) ) ) { // phpcs:ignore
                $this->is_initialized        = false;
                $this->initialization_result = $result;
Severity: Minor
Found in src/includes/Actions/Initializable/InitializableTrait.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 setup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function setup(): ?SetupFailureException {
        if ( \is_null( $this->is_setup ) ) {
            if ( ! \is_null( $result = $this->maybe_execute_local_trait( SetupLocalTrait::class, 'setup' ) ) ) { // phpcs:ignore
                $this->is_setup     = false;
                $this->setup_result = $result;
Severity: Minor
Found in src/includes/Actions/Setupable/SetupableTrait.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 output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function output(): ?OutputFailureException {
        if ( \is_null( $this->is_outputted ) ) {
            if ( ! \is_null( $result = $this->maybe_execute_local_trait( OutputLocalTrait::class, 'output' ) ) ) { // phpcs:ignore
                $this->is_outputted  = false;
                $this->output_result = $result;
Severity: Minor
Found in src/includes/Actions/Outputtable/OutputtableTrait.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