divineniiquaye/rade-di

View on GitHub

Showing 100 of 100 total issues

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

    private function mergeConfig(array $a, array $b, bool $replace): array
    {
        foreach ($b as $k => $v) {
            if (\array_key_exists($k, $a)) {
                if (!\is_array($v)) {
Severity: Minor
Found in src/Extensions/ExtensionBuilder.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 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 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

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

    public function getConfig(string $extensionName, string $parent = null)
    {
        $configuration = &$this->configuration;

        if (!(\array_key_exists($extensionName, $this->extensions) || \array_key_exists($extensionName, $this->aliases))) {
Severity: Minor
Found in src/Extensions/ExtensionBuilder.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 deeply nested control flow statements.
Open

                        if (null === $class) {
                            return [];
                        }
Severity: Major
Found in src/Resolver.php - About 45 mins to fix

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

        public function resolveServiceSubscriber($id, string $value): array
        {
            $service = fn () => $this->resolveReference($value);
    
            if (null !== $this->builder) {
    Severity: Minor
    Found in src/Resolver.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 buildTraits has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function buildTraits(string $cacheDirectory, array $includePaths = []): string
        {
            $traitsDirectory = \rtrim($cacheDirectory, '/') . '/Definitions' . $this->traitHash($cacheDirectory);
            $autoLoadAst = [];
    
    
    Severity: Minor
    Found in src/NodeVisitor/DefinitionsSplitter.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 load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function load($file, string $type = null): void
        {
            $file = \rtrim($file, '/');
            $path = $this->locator->locate($file);
            $container = $this->builder->getContainer();
    Severity: Minor
    Found in src/Loader/DirectoryLoader.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 set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function set(string $id, mixed $definition = null): Definition
        {
            if (isset($this->methodsMap[$id]) || isset($this->services[$id]) || isset($this->privates[$id])) {
                throw new FrozenServiceException(\sprintf('The "%s" service is already initialized, and cannot be replaced.', $id));
            }
    Severity: Minor
    Found in src/Traits/DefinitionTrait.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 replace has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function replace(mixed $entity, bool $preserveTypes = false)
        {
            if ($entity instanceof Definitions\Statement) {
                $this->args($entity->getArguments());
                $this->lazy($entity->isClosureWrappable());
    Severity: Minor
    Found in src/Definition.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 removeType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function removeType(string $type, string $serviceId = null): void
        {
            if (null !== $serviceId) {
                foreach ($this->types[$type] ?? [] as $offset => $typed) {
                    if ($serviceId === $typed) {
    Severity: Minor
    Found in src/Traits/TypesTrait.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 getDefinitionClass has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function getDefinitionClass(Definition $def): ?string
        {
            if (!\is_string($class = $def->getEntity())) {
                return null;
            }
    Severity: Minor
    Found in src/Resolver.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 runScope has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function runScope(array $services, callable $scope): mixed
        {
            $ref = new \ReflectionFunction(\Closure::fromCallable($scope));
    
            foreach ($services as $serviceId) {
    Severity: Minor
    Found in src/Container.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 typed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function typed(string $id, bool $ids = false): array|bool
        {
            if (!$this->has($id)) {
                return $ids ? $this->types[$id] ?? [] : !empty($this->types[$id] ?? []);
            }
    Severity: Minor
    Found in src/Traits/TypesTrait.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 doReplacement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        private function doReplacement(\PhpParser\Node &$nodeValue, string $parentId, bool $leaveNodes, ?bool &$replaced = false): void
        {
            if ($nodeValue instanceof Expr\Variable || $nodeValue instanceof \PhpParser\Node\FunctionLike) {
                return; // @Todo: work in progress ...
            }
    Severity: Minor
    Found in src/NodeVisitor/AutowiringResolver.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 removeBinding has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function removeBinding(int|string $propertyOrMethod): void
        {
            if (\is_string($propertyOrMethod)) {
                $type = 'b';
    
    
    Severity: Minor
    Found in src/Definition.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 removeTag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function removeTag(string $tag, string ...$only): void
        {
            if (empty($only)) {
                unset($this->tags[$tag]);
    
    
    Severity: Minor
    Found in src/Traits/TagsTrait.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 getParameterDefaultValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function getParameterDefaultValue(\ReflectionParameter $parameter, array $types)
        {
            if ($parameter->isOptional() || $parameter->allowsNull()) {
                return null;
            }
    Severity: Minor
    Found in src/Resolver.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

    Avoid too many return statements within this method.
    Open

                            return $this->get($itemType);
    Severity: Major
    Found in src/Resolver.php - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language