zharinovkv/php-project-lvl2

View on GitHub

Showing 11 of 11 total issues

Method format has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function format($ast)
{
    $inner = function ($innerData, $depth) use (&$inner) {

        $mapper = function ($child) use ($depth, &$inner) {
Severity: Minor
Found in src/Formatters/pretty.php - About 1 hr to fix

    Method format has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function format($ast)
    {
        $inner = function ($innerData, $nameGroup) use (&$inner) {
    
            $mapper = function ($child) use ($nameGroup, $inner) {
    Severity: Minor
    Found in src/Formatters/plain.php - About 1 hr to fix

      Function buildAst has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function buildAst($dataBefore, $dataAfter)
      {
          $keys = array_keys(array_merge(get_object_vars($dataBefore), get_object_vars($dataAfter)));
      
          $mapper = function ($key) use ($dataBefore, $dataAfter) {
      Severity: Minor
      Found in src/ast.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 array_map($mapper, $keys);
      Severity: Major
      Found in src/ast.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return $inner($child['children'], "{$child['name']}.");
        Severity: Major
        Found in src/Formatters/plain.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return array_map($mapper, $innerData);
          Severity: Major
          Found in src/Formatters/pretty.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return "{\n{$joined}\n}";
            Severity: Major
            Found in src/Formatters/pretty.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return $inner($ast, null);
              Severity: Major
              Found in src/Formatters/plain.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return join("\n", $group);
                Severity: Major
                Found in src/Formatters/pretty.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return [
                                  'type' => 'changed',
                                  'name' => $key,
                                  'valueBefore' => $dataBefore->$key,
                                  'valueAfter' => $dataAfter->$key
                  Severity: Major
                  Found in src/ast.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return join("\n", $filtered);
                    Severity: Major
                    Found in src/Formatters/plain.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language