src/Phan/Issue.php

Summary

Maintainability
F
1 mo
Test Coverage

The method Issue::fromType() calls the typical debug function debug_print_backtrace() which is mostly only used during development.
Open

            \debug_print_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
Severity: Minor
Found in src/Phan/Issue.php by phpmd

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

Method generateIssueMap has 4385 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function generateIssueMap(): array
    {
        // phpcs:disable Generic.Files.LineLength
        /**
         * @var list<Issue>
Severity: Major
Found in src/Phan/Issue.php - About 3 wks to fix

    File Issue.php has 5330 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    namespace Phan;
    Severity: Major
    Found in src/Phan/Issue.php - About 2 wks to fix

      The class Issue has 11 public methods. Consider refactoring Issue to keep number of public methods under 10.
      Open

      class Issue
      {
          // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
          // this is deliberate for issue names
          // Issue::CATEGORY_SYNTAX
      Severity: Minor
      Found in src/Phan/Issue.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class Issue has an overall complexity of 50 which is very high. The configured complexity threshold is 50.
      Open

      class Issue
      {
          // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
          // this is deliberate for issue names
          // Issue::CATEGORY_SYNTAX
      Severity: Minor
      Found in src/Phan/Issue.php by phpmd

      Issue has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Issue
      {
          // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
          // this is deliberate for issue names
          // Issue::CATEGORY_SYNTAX
      Severity: Minor
      Found in src/Phan/Issue.php - About 3 hrs to fix

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

            private static function sanityCheckErrorList(array $error_list): void
            {
                $error_map = [];
                $unique_type_id_set = [];
                foreach ($error_list as $error) {
        Severity: Minor
        Found in src/Phan/Issue.php - About 1 hr to fix

          Function sanityCheckErrorList has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function sanityCheckErrorList(array $error_list): void
              {
                  $error_map = [];
                  $unique_type_id_set = [];
                  foreach ($error_list as $error) {
          Severity: Minor
          Found in src/Phan/Issue.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

          Method maybeEmitWithParameters has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  CodeBase $code_base,
                  Context $context,
                  string $issue_type,
                  int $lineno,
                  array $parameters,
          Severity: Major
          Found in src/Phan/Issue.php - About 50 mins to fix

            Method shouldSuppressIssue has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    CodeBase $code_base,
                    Context $context,
                    string $issue_type,
                    int $lineno,
                    array $parameters,
            Severity: Minor
            Found in src/Phan/Issue.php - About 45 mins to fix

              Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      string $type,
                      int $category,
                      int $severity,
                      string $template_raw,
                      int $remediation_difficulty,
              Severity: Minor
              Found in src/Phan/Issue.php - About 45 mins to fix

                Method emitWithParameters has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        string $type,
                        string $file,
                        int $line,
                        array $template_parameters,
                        Suggestion $suggestion = null,
                Severity: Minor
                Found in src/Phan/Issue.php - About 45 mins to fix

                  Method __invoke has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          string $file,
                          int $line,
                          array $template_parameters = [],
                          Suggestion $suggestion = null,
                          int $column = 0
                  Severity: Minor
                  Found in src/Phan/Issue.php - About 35 mins to fix

                    Method maybeEmit has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            CodeBase $code_base,
                            Context $context,
                            string $issue_type,
                            int $lineno,
                            ...$parameters
                    Severity: Minor
                    Found in src/Phan/Issue.php - About 35 mins to fix

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

                          private static function getNextTypeId(array $issue_list, int $invalid_type_id): int
                          {
                              for ($id = $invalid_type_id + 1; true; $id++) {
                                  foreach ($issue_list as $error) {
                                      if ($error->getTypeId() === $id) {
                      Severity: Minor
                      Found in src/Phan/Issue.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 ConfigPluginSet::instance()->shouldSuppressIssue(
                                  $code_base,
                                  $context,
                                  $issue_type,
                                  $lineno,
                      Severity: Major
                      Found in src/Phan/Issue.php - About 30 mins to fix

                        The class Issue has 5671 lines of code. Current threshold is 1000. Avoid really long classes.
                        Open

                        class Issue
                        {
                            // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
                            // this is deliberate for issue names
                            // Issue::CATEGORY_SYNTAX
                        Severity: Minor
                        Found in src/Phan/Issue.php by phpmd

                        The method generateIssueMap() has 4448 lines of code. Current threshold is set to 100. Avoid really long methods.
                        Open

                            private static function generateIssueMap(): array
                            {
                                // phpcs:disable Generic.Files.LineLength
                                /**
                                 * @var list<Issue>
                        Severity: Minor
                        Found in src/Phan/Issue.php by phpmd

                        There are no issues that match your filters.

                        Category
                        Status