Showing 3,272 of 4,939 total issues

Function recordLoopContextForBreakOrContinue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function recordLoopContextForBreakOrContinue(Context $child_context): void
    {
        for ($i = \count($this->parent_node_list) - 1; $i >= 0; $i--) {
            $node = $this->parent_node_list[$i];
            switch ($node->kind) {
Severity: Minor
Found in src/Phan/BlockAnalysisVisitor.php - About 25 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 createVarForInlineComment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function createVarForInlineComment(CodeBase $code_base, Context $context, string $variable_name, UnionType $type, bool $create_variable): void
    {
        if (!$context->getScope()->hasVariableWithName($variable_name)) {
            if (Variable::isHardcodedVariableInScopeWithName($variable_name, $context->isInGlobalScope())) {
                return;
Severity: Minor
Found in src/Phan/BlockAnalysisVisitor.php - About 25 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 shouldSuggestProperty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function shouldSuggestProperty(Context $context, Clazz $class_in_scope, Property $property): bool
    {
        if ($property->isDynamicProperty()) {
            // Don't suggest properties that weren't declared.
            return false;
Severity: Minor
Found in src/Phan/IssueFixSuggester.php - About 25 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 visitDoWhile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitDoWhile(Node $node): Context
    {
        $context = $this->context;
        $context->setLineNumberStart($node->lineno);
        $context = $context->withEnterLoop($node);
Severity: Minor
Found in src/Phan/BlockAnalysisVisitor.php - About 25 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 isSecondArgumentEqualToConst has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function isSecondArgumentEqualToConst(Node $node, string $const_name): bool
    {
        $args = $node->children['args']->children;
        $bool_node = $args[1] ?? null;
        if (!$bool_node instanceof Node) {
Severity: Minor
Found in src/Phan/Plugin/Internal/UseReturnValuePlugin/UseReturnValueVisitor.php - About 25 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 updateClosestTargetPHPVersion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function updateClosestTargetPHPVersion(): void
    {
        $value = self::$configuration['target_php_version'];
        if (is_int($value) || is_float($value)) {
            $value = \sprintf("%.1f", $value);
Severity: Minor
Found in src/Phan/Config.php - About 25 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 backtrace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function backtrace(int $levels = 0): void
    {
        $bt = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, $levels + 1);
        foreach ($bt as $level => $context) {
            if (!$level) {
Severity: Minor
Found in src/Phan/Debug.php - About 25 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 isSafeNodeToSubstitute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function isSafeNodeToSubstitute(Context $context, $value_node): bool
    {
        if (!$value_node instanceof Node) {
            // TODO: floats might lose precision when converted back to strings by phantasm. Use the original expression based on the parent node?
            return \is_int($value_node) || \is_string($value_node);  // not null
Severity: Minor
Found in src/Phan/Plugin/Internal/PhantasmPlugin/PhantasmVisitor.php - About 25 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 checkIsReadOnlyFunctionCommon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkIsReadOnlyFunctionCommon(CodeBase $code_base, FunctionInterface $method, PureMethodGraph $graph): void
    {
        if ($method->getFlags() & ast\flags\FUNC_RETURNS_REF) {
            return;
        }
Severity: Minor
Found in src/Phan/Plugin/Internal/UseReturnValuePlugin/PureMethodInferrer.php - About 25 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 warnNoopVoid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function warnNoopVoid(CodeBase $code_base, FunctionInterface $method): void
    {
        if ($method instanceof Method) {
            if ($method->isMagic()) {
                return;
Severity: Minor
Found in src/Phan/Plugin/Internal/UseReturnValuePlugin/PureMethodInferrer.php - About 25 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 wrapNArgumentFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function wrapNArgumentFunction(
        string $function_name,
        int $min_args,
        ?int $max_args = null
    ): Closure {
Severity: Minor
Found in src/Phan/Plugin/Internal/ExtendedDependentReturnTypeOverridePlugin.php - About 25 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 makeSuggestion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function makeSuggestion(VariableGraph $graph, string $variable_name, string $issue_type): ?Suggestion
    {
        if ($issue_type !== Issue::UnusedVariable) {
            return null;
        }
Severity: Minor
Found in src/Phan/Plugin/Internal/VariableTrackerPlugin.php - About 25 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 analyzeFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function analyzeFunction(
        CodeBase $code_base,
        Func $function
    ): void {
        if ($function->isPHPInternal()) {
Severity: Minor
Found in src/Phan/Plugin/Internal/DumpPHPDocPlugin.php - About 25 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 visitIncludeOrEval has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitIncludeOrEval(Node $node): void
    {
        if ($node->flags === ast\flags\EXEC_EVAL) {
            $this->analyzeEval($node);
            return;
Severity: Minor
Found in src/Phan/Plugin/Internal/RequireExistsPlugin.php - About 25 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 checkImpossibleMatchArm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkImpossibleMatchArm(
        $cond_node,
        UnionType $cond_type,
        Node $arm_node
    ): void {
Severity: Minor
Found in src/Phan/Plugin/Internal/RedundantConditionVisitor.php - About 25 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 shouldCheckScalarAsIfInLoopScope has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function shouldCheckScalarAsIfInLoopScope(Node $node, $evaluated_value): bool
    {
        if (!$this->context->isInLoop()) {
            // This isn't even in a loop.
            return false;
Severity: Minor
Found in src/Phan/Plugin/Internal/RedundantConditionVisitor.php - About 25 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 visitIsset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitIsset(Node $node): void
    {
        $var_node = $node->children['var'];
        try {
            $type = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $var_node, false);
Severity: Minor
Found in src/Phan/Plugin/Internal/RedundantConditionVisitor.php - About 25 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 visitInstanceof has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitInstanceof(Node $node): void
    {
        $expr_node = $node->children['expr'];
        $code_base = $this->code_base;
        try {
Severity: Minor
Found in src/Phan/Plugin/Internal/RedundantConditionVisitor.php - About 25 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 checkImpossibleComparison has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkImpossibleComparison(Node $node, bool $strict): void
    {
        $left = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $node->children['left']);
        if (!$left->hasRealTypeSet()) {
            return;
Severity: Minor
Found in src/Phan/Plugin/Internal/RedundantConditionVisitor.php - About 25 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 computeCommonDefsShadowingSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function computeCommonDefsShadowingSet(array $branch_scopes): array
    {
        $result = null;
        foreach ($branch_scopes as $scope) {
            $deps = $scope->defs_shadowing_set;
Severity: Minor
Found in src/Phan/Plugin/Internal/VariableTracker/VariableTrackingScope.php - About 25 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

Severity
Category
Status
Source
Language