fey/php-project-lvl2

View on GitHub
src/Formatters/Stylish.php

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

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

function format(array $diff): string
{
    $format = function ($diff, $level) use (&$format) {
        return array_map(
            function ($node) use ($level, $format) {
Severity: Minor
Found in src/Formatters/Stylish.php - About 1 hr to fix

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

    function formatMessage(int $indentLevel, string $mark, string $nodeName, $value): string
    {
        $stringifyComplexValue = fn($complexValue, $level) => implode(
            END_OF_LINE,
            [
    Severity: Minor
    Found in src/Formatters/Stylish.php - About 1 hr to fix

      syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ']'
      Open

                          NESTED    => fn() => formatMessage(
      Severity: Critical
      Found in src/Formatters/Stylish.php by phan

      Avoid excessively long variable names like $stringifyComplexValue. Keep variable name length under 20.
      Open

          $stringifyComplexValue = fn($complexValue, $level) => implode(
      Severity: Minor
      Found in src/Formatters/Stylish.php by phpmd

      LongVariable

      Since: 0.2

      Detects when a field, formal or local variable is declared with a long name.

      Example

      class Something {
          protected $reallyLongIntName = -3; // VIOLATION - Field
          public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
              $otherReallyLongName = -5; // VIOLATION - Local
              for ($interestingIntIndex = 0; // VIOLATION - For
                   $interestingIntIndex < 10;
                   $interestingIntIndex++ ) {
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#longvariable

      There must be one USE keyword per declaration
      Open

      use const GenDiff\Diff\{ADDED, CHANGED, NESTED, REMOVED, UNCHANGED};
      Severity: Minor
      Found in src/Formatters/Stylish.php by phpcodesniffer

      Only one argument is allowed per line in a multi-line function call
      Open

                      fn($value, $key) => formatMessage($indentLevel + 1, MARK_SPACES, $key, $value),
      Severity: Minor
      Found in src/Formatters/Stylish.php by phpcodesniffer

      Only one argument is allowed per line in a multi-line function call
      Open

                      fn($value, $key) => formatMessage($indentLevel + 1, MARK_SPACES, $key, $value),
      Severity: Minor
      Found in src/Formatters/Stylish.php by phpcodesniffer

      Only one argument is allowed per line in a multi-line function call
      Open

                      fn($value, $key) => formatMessage($indentLevel + 1, MARK_SPACES, $key, $value),
      Severity: Minor
      Found in src/Formatters/Stylish.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status