divineniiquaye/rade-di

View on GitHub
src/Traits/DefinitionAwareTrait.php

Summary

Maintainability
F
3 days
Test Coverage

Function resolve has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolve(Resolver $resolver, bool $createMethod = false): mixed
    {
        if (($this->options['abstract'] ?? false)) {
            throw new ContainerResolutionException(\sprintf('Resolving an abstract definition %s is not allowed.', $this->id));
        }
Severity: Minor
Found in src/Traits/DefinitionAwareTrait.php - About 1 day 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 build has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    protected function build(Resolver $resolver, p\BuilderFactory $builder, bool $createMethod): p\Node\Expr|p\Node\Stmt\ClassMethod
    {
        $defNode = $builder->method($resolver::createMethod($this->id))->makeProtected();
        $defTyped = $defNodes = [];

Severity: Minor
Found in src/Traits/DefinitionAwareTrait.php - About 1 day 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 build has 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function build(Resolver $resolver, p\BuilderFactory $builder, bool $createMethod): p\Node\Expr|p\Node\Stmt\ClassMethod
    {
        $defNode = $builder->method($resolver::createMethod($this->id))->makeProtected();
        $defTyped = $defNodes = [];

Severity: Major
Found in src/Traits/DefinitionAwareTrait.php - About 4 hrs to fix

    Method resolve has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function resolve(Resolver $resolver, bool $createMethod = false): mixed
        {
            if (($this->options['abstract'] ?? false)) {
                throw new ContainerResolutionException(\sprintf('Resolving an abstract definition %s is not allowed.', $this->id));
            }
    Severity: Major
    Found in src/Traits/DefinitionAwareTrait.php - About 2 hrs to fix

      Function setContainer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setContainer(Container $container, string $id, bool $anonymous = false)
          {
              $this->container = $container;
              $this->id = $id;
      
      
      Severity: Minor
      Found in src/Traits/DefinitionAwareTrait.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 methodExists has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function methodExists(mixed $entity, string $method): bool
          {
              if (\is_string($entity)) {
                  return \method_exists($entity, $method);
              }
      Severity: Minor
      Found in src/Traits/DefinitionAwareTrait.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

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in src/Traits/DefinitionAwareTrait.php - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status