Showing 3,272 of 4,939 total issues

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

function getParameterCountsFromReflection(array $args): array
{
    $num_required = 0;
    $num_optional = count($args);
    foreach ($args as $reflection_parameter) {
Severity: Minor
Found in internal/sanitycheck.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 getInternalClasses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function getInternalClasses(): Generator
    {
        $classes = array_merge(
            get_declared_classes(),
            get_declared_interfaces(),
Severity: Minor
Found in internal/reflection_completeness_check.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 awaitIncompleteProcesses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function awaitIncompleteProcesses(CodeBase $code_base, int $max_incomplete_processes): void
    {
        foreach ($this->processes as $i => $process) {
            if (!$process->read()) {
                continue;
Severity: Minor
Found in .phan/plugins/InvokePHPNativeSyntaxCheckPlugin.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 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 hasTODOComment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function hasTODOComment(int $lineno, Node $analyzed_node, ?int $end_lineno = null): bool
    {
        if (EmptyStatementListPlugin::$ignore_todos) {
            return false;
        }
Severity: Minor
Found in .phan/plugins/EmptyStatementListPlugin.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

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

    public function visitTry(Node $node): void
    {
        ['try' => $try_node, 'finally' => $finally_node] = $node->children;
        if (!$try_node->children) {
            if (!$this->hasTODOComment($try_node->lineno, $node, $node->children['catches']->children[0]->lineno ?? $finally_node->lineno ?? null)) {
Severity: Minor
Found in .phan/plugins/EmptyStatementListPlugin.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 getAnalyzeFunctionCallClosures has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAnalyzeFunctionCallClosures(CodeBase $code_base): array
    {
        // @phan-suppress-next-line PhanThrowTypeAbsentForCall
        $assert_class_fqsen = FullyQualifiedClassName::fromFullyQualifiedString('PHPUnit\Framework\Assert');
        if (!$code_base->hasClassWithFQSEN($assert_class_fqsen)) {
Severity: Minor
Found in .phan/plugins/PHPUnitAssertionPlugin.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 analyzeMethod has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function analyzeMethod(
        CodeBase $code_base,
        Method $method
    ): void {
        if ($method->getFQSEN() !== $method->getRealDefiningFQSEN()) {
Severity: Minor
Found in .phan/plugins/UnknownElementTypePlugin.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 generateCompletionsFromCandidates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateCompletionsFromCandidates(array $candidates, string $prefix, string $prefix_to_add_to_completion): array
    {
        $prefix_len = strlen($prefix);
        $completions = [];
        foreach ($candidates as $candidate) {
Severity: Minor
Found in tool/phan_repl_helpers.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 analyzeReplacementTemplate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function analyzeReplacementTemplate(CodeBase $code_base, Context $context, array $patterns, $replacement_node): void
    {
        $replacement_templates = self::extractStringsFromStringOrArray($code_base, $context, $replacement_node);
        $pattern_keys = null;

Severity: Minor
Found in .phan/plugins/PregRegexCheckerPlugin.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 checkBinaryOpOfConditional has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkBinaryOpOfConditional(Node $cond_node, $true_node_hash): void
    {
        if ($cond_node->flags !== ast\flags\BINARY_IS_NOT_IDENTICAL) {
            return;
        }
Severity: Minor
Found in .phan/plugins/DuplicateExpressionPlugin.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 analyzeFunctionLike has a Cognitive Complexity of 7 (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/PHPDocRedundantPlugin.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 isSelfOrParentCallUsingObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function isSelfOrParentCallUsingObject(CodeBase $code_base, FunctionInterface $method, Node $node): bool
    {
        $class_node = $node->children['class'];
        if (!($class_node instanceof Node && $class_node->kind === ast\AST_NAME)) {
            return false;
Severity: Minor
Found in .phan/plugins/PossiblyStaticMethodPlugin.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 analyzeMethod has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function analyzeMethod(
        CodeBase $code_base,
        Method $method
    ): void {
        // 1. Perform any checks that can be done immediately to rule out being able
Severity: Minor
Found in .phan/plugins/PossiblyStaticMethodPlugin.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 visitConst has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitConst(Node $node): void
    {
        $expression = $node->children['name'];
        if (!($expression instanceof Node) || $expression->kind !== ast\AST_NAME) {
            return;
Severity: Minor
Found in .phan/plugins/NotFullyQualifiedUsagePlugin.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 get_class($value) . '(' . $value->getRepresentationForIssue() . ')';
Severity: Major
Found in src/Phan/Debug/Frame.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return true;
    Severity: Major
    Found in src/Phan/CLI.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return count($value) > 0 ? '[...]' : '[]';
      Severity: Major
      Found in src/Phan/Debug/Frame.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return '[' . \implode(', ', $result) . ']';
        Severity: Major
        Found in src/Phan/Debug/Frame.php - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language