divineniiquaye/rade-di

View on GitHub
src/DefinitionBuilder.php

Summary

Maintainability
D
2 days
Test Coverage

Function findClasses has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    private function findClasses(string $namespace, string $pattern, array $excludePatterns): array
    {
        $classNames = [];
        $container = $this->container;

Severity: Minor
Found in src/DefinitionBuilder.php - About 6 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

File DefinitionBuilder.php has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/*
Severity: Minor
Found in src/DefinitionBuilder.php - About 3 hrs to fix

    Function findResourcePath has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        private function findResourcePath(string $namespace): string
        {
            foreach (\spl_autoload_functions() as $classLoader) {
                if (!\is_array($classLoader)) {
                    continue;
    Severity: Minor
    Found in src/DefinitionBuilder.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

    DefinitionBuilder has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DefinitionBuilder implements ResetInterface
    {
        private ?string $definition = null, $directory = null;
        private bool $trackDefaults = false, $condition = true;
    
    
    Severity: Minor
    Found in src/DefinitionBuilder.php - About 2 hrs to fix

      Function doCreate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          private function doCreate(object $definition): void
          {
              $this->trackDefaults = false;
      
              foreach ($this->defaults as $offset => $defaultMethods) {
      Severity: Minor
      Found in src/DefinitionBuilder.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

      Method findClasses has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function findClasses(string $namespace, string $pattern, array $excludePatterns): array
          {
              $classNames = [];
              $container = $this->container;
      
      
      Severity: Minor
      Found in src/DefinitionBuilder.php - About 1 hr to fix

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

            public function namespaced(string $namespace, string $resource = null, $exclude = null)
            {
                if (!$this->condition) {
                    return $this;
                }
        Severity: Minor
        Found in src/DefinitionBuilder.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 findClass has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private function findClass(Container $container, string $class, string $path, string $pattern): ?string
            {
                if (!\preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+$/', $class)) {
                    return null;
                }
        Severity: Minor
        Found in src/DefinitionBuilder.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 __destruct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __destruct()
            {
                if (!empty($this->classes)) {
                    foreach ($this->classes as [$definition, $classes]) {
                        // prepare for deep cloning
        Severity: Minor
        Found in src/DefinitionBuilder.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 __call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __call(string $name, array $arguments)
            {
                if (!$this->condition) {
                    return $this;
                }
        Severity: Minor
        Found in src/DefinitionBuilder.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