Showing 3,272 of 4,939 total issues

Function normalizeForStatement has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private static function normalizeForStatement(Node $node): array
    {
        // Repeatedly apply these rules
        while (true) {
            $for_cond_list = $node->children['cond'];
Severity: Minor
Found in src/Phan/AST/ASTSimplifier.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 checkInvalidUnpackKeyType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkInvalidUnpackKeyType(Node $node, UnionType $union_type, bool $is_array_spread): void
    {
        $is_invalid_because_associative = false;
        if (!$is_array_spread) {
            foreach ($union_type->getTypeSet() as $type) {
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.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 initInner has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private static function initInner(): void
    {
        /**
         * @param Node $node
         */
Severity: Minor
Found in src/Phan/AST/PhanAnnotationAdder.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 getClassConst has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function getClassConst(): ClassConstant
    {
        $node = $this->node;
        if (!($node instanceof Node)) {
            throw new AssertionError('$this->node must be a node');
Severity: Minor
Found in src/Phan/AST/ContextNode.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 extractInfoFromOpcache has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private static function extractInfoFromOpcache(string $contents): array
    {
        $lines = explode("\n", $contents);
        $result = [];
        foreach ($lines as $line) {
Severity: Minor
Found in internal/extract_arg_info.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 getMethodsForClassName has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMethodsForClassName(string $class_name): ?array
    {
        $class_name_lc = strtolower($class_name);
        $class_name_file_map = $this->getFoldersForClassNameList();
        $class_name_files = $class_name_file_map[$class_name_lc] ?? null;
Severity: Minor
Found in internal/lib/IncompatibleXMLSignatureDetector.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 finalizeProcess has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function finalizeProcess(CodeBase $code_base): void
    {
        echo "<" . "?php declare(strict_types=1);\n";
        ksort(self::$calls);
        foreach (self::$calls as $namespace => $name_set) {
Severity: Minor
Found in internal/lib/NotFullyQualifiedReporterPlugin.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 findCycles has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function findCycles(array $destination_map): array
    {
        $result = [];
        while (count($destination_map) > 0) {
            reset($destination_map);
Severity: Minor
Found in .phan/plugins/SuspiciousParamOrderPlugin.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 analyzeFunctionLike has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private static function analyzeFunctionLike(CodeBase $code_base, FunctionInterface $method): void
    {
        if (Phan::isExcludedAnalysisFile($method->getContext()->getFile())) {
            // This has no side effects, so we can skip files that don't need to be analyzed
            return;
Severity: Minor
Found in .phan/plugins/PHPDocToRealTypesPlugin.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 streamPutContents has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private static function streamPutContents($stream, string $file_contents): void
    {
        try {
            while (strlen($file_contents) > 0) {
                $bytes_written = fwrite($stream, $file_contents);
Severity: Minor
Found in .phan/plugins/InvokePHPNativeSyntaxCheckPlugin.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

Method ensureASTParserExists has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function ensureASTParserExists(): void
    {
        if (Config::getValue('use_polyfill_parser')) {
            return;
        }
Severity: Minor
Found in src/Phan/CLI.php - About 1 hr to fix

    Method build has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function build(): Comment
        {
            foreach ($this->lines as $i => $line) {
                if (\strpos($line, '@') === false) {
                    continue;
    Severity: Minor
    Found in src/Phan/Language/Element/Comment/Builder.php - About 1 hr to fix

      Method applyOverride has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function applyOverride(string $key, $value): void
          {
              switch ($key) {
                  case 'param':
                      foreach ($value as $parameter) {
      Severity: Minor
      Found in src/Phan/Language/Element/Comment.php - About 1 hr to fix

        Method internalFunctionSignatureMap has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function internalFunctionSignatureMap(int $target_php_version): array
            {
                static $php73_map = [];
        
                if (!$php73_map) {
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 1 hr to fix

          Method asClassList has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function asClassList(
                  CodeBase $code_base,
                  Context $context
              ): Generator {
                  // Iterate over each viable class type to see if any
          Severity: Minor
          Found in src/Phan/Language/UnionType.php - About 1 hr to fix

            Method checkMultipleReturns has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function checkMultipleReturns(array $possible_return_nodes): void
                {
                    if (\count($possible_return_nodes) <= 1) {
                        return;
                    }

              Method analyzeReferenceCounts has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function analyzeReferenceCounts(CodeBase $code_base): void
                  {
                      // Check to see if dead code detection is enabled. Keep
                      // in mind that the results here are just a guess and
                      // we can't tell with certainty that anything is
              Severity: Minor
              Found in src/Phan/Analysis/ReferenceCountsAnalyzer.php - About 1 hr to fix

                Method checkComplexIsset has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function checkComplexIsset(Node $var_node): Context
                    {
                        $context = $this->context;
                        if ($var_node->kind === ast\AST_DIM) {
                            $expr_node = $var_node;
                Severity: Minor
                Found in src/Phan/Analysis/NegatedConditionVisitor.php - About 1 hr to fix

                  Method visitArrowFunc has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function visitArrowFunc(Node $node): Context
                      {
                          $code_base = $this->code_base;
                          $context = $this->context->withoutLoops();
                          $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext(
                  Severity: Minor
                  Found in src/Phan/Analysis/PreOrderAnalysisVisitor.php - About 1 hr to fix

                    Method normalizeListTypesInDimAssignment has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static function normalizeListTypesInDimAssignment(UnionType $assign_type, UnionType $right_type): UnionType
                        {
                            // Offsets of $can_cast:
                            // 0. lazily computed: True if list types should be kept as-is.
                            // 1. lazily computed: Should this cast from a regular array to an associative array?
                    Severity: Minor
                    Found in src/Phan/Analysis/AssignmentVisitor.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language