.phan/plugins/HasPHPDocPlugin.php

Summary

Maintainability
D
1 day
Test Coverage

File HasPHPDocPlugin.php has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace HasPHPDocPlugin;
Severity: Minor
Found in .phan/plugins/HasPHPDocPlugin.php - About 3 hrs to fix

    Method checkMethodDescription has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function checkMethodDescription(Clazz $class, Node $node): ?ClassElementEntry
        {
            $method_name = (string)$node->children['name'];
            $method = $class->getMethodByName($this->code_base, $method_name);
            if ($method->isMagic()) {
    Severity: Minor
    Found in .phan/plugins/HasPHPDocPlugin.php - About 1 hr to fix

      Method visitClass has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function visitClass(Node $node): array
          {
              [$property_descriptions, $method_descriptions] = parent::visitClass($node);
              foreach (self::findGroups($property_descriptions) as $entries) {
                  $first_entry = array_shift($entries);
      Severity: Minor
      Found in .phan/plugins/HasPHPDocPlugin.php - About 1 hr to fix

        Method analyzeFunction has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function analyzeFunction(
                CodeBase $code_base,
                Func $function
            ): void {
                if ($function->isPHPInternal()) {
        Severity: Minor
        Found in .phan/plugins/HasPHPDocPlugin.php - About 1 hr to fix

          Method checkPropGroupDescription has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function checkPropGroupDescription(Clazz $class, Node $node): ?ClassElementEntry
              {
                  $property_name = $node->children['props']->children[0]->children['name'] ?? null;
                  if (!is_string($property_name)) {
                      return null;
          Severity: Minor
          Found in .phan/plugins/HasPHPDocPlugin.php - About 1 hr to fix

            Method analyzeClass has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function analyzeClass(
                    CodeBase $code_base,
                    Clazz $class
                ): void {
                    if ($class->isAnonymous()) {
            Severity: Minor
            Found in .phan/plugins/HasPHPDocPlugin.php - About 1 hr to fix

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

                  public function visitClass(Node $node): array
                  {
                      $class = $this->context->getClassInScope($this->code_base);
                      $property_descriptions = [];
                      $method_descriptions = [];
              Severity: Minor
              Found in .phan/plugins/HasPHPDocPlugin.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 visitClass has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function visitClass(Node $node): array
                  {
                      [$property_descriptions, $method_descriptions] = parent::visitClass($node);
                      foreach (self::findGroups($property_descriptions) as $entries) {
                          $first_entry = array_shift($entries);
              Severity: Minor
              Found in .phan/plugins/HasPHPDocPlugin.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 checkMethodDescription has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function checkMethodDescription(Clazz $class, Node $node): ?ClassElementEntry
                  {
                      $method_name = (string)$node->children['name'];
                      $method = $class->getMethodByName($this->code_base, $method_name);
                      if ($method->isMagic()) {
              Severity: Minor
              Found in .phan/plugins/HasPHPDocPlugin.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 findGroups has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private static function findGroups(array $values): array
                  {
                      $result = [];
                      foreach ($values as $v) {
                          if ($v->element->isDeprecated()) {
              Severity: Minor
              Found in .phan/plugins/HasPHPDocPlugin.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;
              Severity: Major
              Found in .phan/plugins/HasPHPDocPlugin.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return new ClassElementEntry($method, \trim(\preg_replace('/\s+/', ' ', $description)));
                Severity: Major
                Found in .phan/plugins/HasPHPDocPlugin.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return null;
                  Severity: Major
                  Found in .phan/plugins/HasPHPDocPlugin.php - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status