peakphp/framework

View on GitHub

Showing 34 of 34 total issues

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

    public function resolve(array $definition, Container $container, array $args = [])
    {
        $final_args = $definition;
        if (!empty($args)) { // add create argument at the end
            foreach ($args as $arg) {
Severity: Minor
Found in src/Di/ArrayDefinition.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

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

    public function resolve($class, Container $container, array $args = [], $explicit = null)
    {
        $method = '__construct';

        if (is_array($class)) {
Severity: Minor
Found in src/Di/ClassResolver.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 inspectRecursive has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function inspectRecursive(array $handlers): array
    {
        $routes = [];
        foreach ($handlers as $handler) {
            $subRoutes = [];
Severity: Minor
Found in src/Backpack/Bedrock/AppRoutesMapper.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 set has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function set(string $path, $value): void
    {
        if (!empty($path)) {
            $at = & $this->items;
            $keys = $this->explode($path);
Severity: Minor
Found in src/Collection/DotNotationCollection.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 resolve has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolve(Container $container, array $args = [], $explicit = null)
    {
        $definition = $this->definition;

        if (null !== $this->storedInstance) {
Severity: Minor
Found in src/Di/Binding/Singleton.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

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

<?php

declare(strict_types=1);

namespace Peak\Collection\Structure\Exception;
src/Collection/Structure/Exception/InvalidPropertyDefinitionException.php on lines 1..46

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

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

<?php

declare(strict_types=1);

namespace Peak\Collection\Structure\Exception;
src/Collection/Structure/Exception/UndefinedPropertyException.php on lines 1..46

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

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

Method resolve has 39 lines of code (exceeds 30 allowed). Consider refactoring.
Open

    public function resolve($class, Container $container, array $args = [], $explicit = null)
    {
        $method = '__construct';

        if (is_array($class)) {
Severity: Minor
Found in src/Di/ClassResolver.php - About 1 hr to fix

    Method resolve has 37 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

        public function resolve(array $definition, Container $container, array $args = [])
        {
            $final_args = $definition;
            if (!empty($args)) { // add create argument at the end
                foreach ($args as $arg) {
    Severity: Minor
    Found in src/Di/ArrayDefinition.php - About 1 hr to fix

      Function skipKey has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function skipKey(string $key): bool
          {
              if (!empty($this->search)) {
                  foreach ($this->search as $search) {
                      if ($this->hasWildCard($search)) {
      Severity: Minor
      Found in src/Collection/CollectionFlattener.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 interpolate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          function interpolate(string $message, array $context = array(), Closure $fn = null): string
          {
              // build a replacement array with braces around the context keys
              $replace = array();
              foreach ($context as $key => $val) {
      Severity: Minor
      Found in src/Common/helpers.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 delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function delete($id)
          {
              if ($this->has($id)) {
                  //remove instance
                  unset($this->instances[$id]);
      Severity: Minor
      Found in src/Di/Container.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 resolve has 34 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

          public function resolve(Container $container, array $args = [], $explicit = null)
          {
              $definition = $this->definition;
      
              if (null !== $this->storedInstance) {
      Severity: Minor
      Found in src/Di/Binding/Singleton.php - About 1 hr to fix

        Function inspect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function inspect($class, $method = '__construct')
            {
                if (is_string($class) && !class_exists($class)) {
                    throw new ClassNotFoundException($class);
                }
        Severity: Minor
        Found in src/Di/ClassInspector.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 arrayMergeRecursiveDistinct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function arrayMergeRecursiveDistinct(array $a, array $b, bool $mergeNumericKeys = false): array
            {
                $merged = $a;
        
                foreach($b as $key => $value) {
        Severity: Minor
        Found in src/Common/Traits/ArrayMergeRecursiveDistinct.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 flatCollection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function flatCollection(array $data, string $prefix = null, array $flat_data = []): array
            {
                foreach ($data as $key => $val) {
                    if ($prefix !== null) {
                        $key = $prefix.$this->separator.$key;
        Severity: Minor
        Found in src/Collection/CollectionFlattener.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 resolve has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function resolve($resource): Stream
            {
                // detect best way to load and process configuration content
                if (is_array($resource)) {
                    return new DataStream($resource, new ArrayProcessor());
        Severity: Minor
        Found in src/Config/ConfigResolver.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 __construct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct(array $definitions, bool $strict = false)
            {
                if (empty($definitions)) {
                    return;
                }
        Severity: Minor
        Found in src/Common/PhpIni.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 resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function resolve(string $interface, Container $container, $explicit = [])
            {
                // try to find a match in the container for a class or an interface
                if ($container->hasInterface($interface)) {
                    $instance = $container->getInterface($interface);
        Severity: Minor
        Found in src/Di/InterfaceResolver.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 resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function resolve($item): Bootable
            {
                if(is_string($item) && class_exists($item)) {
                    if (null !== $this->container) {
                        $item = $this->container->get($item);
        Severity: Minor
        Found in src/Bedrock/Bootstrap/BootableResolver.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

        Severity
        Category
        Status
        Source
        Language