laravel/framework

View on GitHub
src/Illuminate/Collections/helpers.php

Summary

Maintainability
D
2 days
Test Coverage

Function data_set has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    function data_set(&$target, $key, $value, $overwrite = true)
    {
        $segments = is_array($key) ? $key : explode('.', $key);

        if (($segment = array_shift($segments)) === '*') {
Severity: Minor
Found in src/Illuminate/Collections/helpers.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

Function data_get has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    function data_get($target, $key, $default = null)
    {
        if (is_null($key)) {
            return $target;
        }
Severity: Minor
Found in src/Illuminate/Collections/helpers.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 data_forget has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    function data_forget(&$target, $key)
    {
        $segments = is_array($key) ? $key : explode('.', $key);

        if (($segment = array_shift($segments)) === '*' && Arr::accessible($target)) {
Severity: Minor
Found in src/Illuminate/Collections/helpers.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

Method data_set has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function data_set(&$target, $key, $value, $overwrite = true)
    {
        $segments = is_array($key) ? $key : explode('.', $key);

        if (($segment = array_shift($segments)) === '*') {
Severity: Minor
Found in src/Illuminate/Collections/helpers.php - About 1 hr to fix

    Method data_get has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function data_get($target, $key, $default = null)
        {
            if (is_null($key)) {
                return $target;
            }
    Severity: Minor
    Found in src/Illuminate/Collections/helpers.php - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

              return $target;
      Severity: Major
      Found in src/Illuminate/Collections/helpers.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return value($default);
        Severity: Major
        Found in src/Illuminate/Collections/helpers.php - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status