Showing 3,272 of 4,939 total issues

Function canCastToNonNullableType has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    protected function canCastToNonNullableType(Type $type): bool
    {
        if ($type instanceof ScalarType) {
            switch ($type::NAME) {
                case 'int':
Severity: Minor
Found in src/Phan/Language/Type/LiteralIntType.php - About 3 hrs 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 __construct has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct(
        array $process_task_data_iterator,
        Closure $startup_closure,
        Closure $task_closure,
        Closure $shutdown_closure
Severity: Minor
Found in src/Phan/ForkPool.php - About 3 hrs 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 checkMultipleReturns has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

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

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 getTypeMatchingBonus has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getTypeMatchingBonus(CodeBase $code_base, UnionType $actual_signature_type, UnionType $desired_type): float
    {
        if (self::isMixed($desired_type) || self::isMixed($actual_signature_type)) {
            return 0;
        }
Severity: Minor
Found in src/Phan/Plugin/Internal/MethodSearcherPlugin.php - About 3 hrs 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 warnAboutPossiblyThrownType has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    protected function warnAboutPossiblyThrownType(
        Node $node,
        FunctionInterface $analyzed_function,
        UnionType $union_type,
        FunctionInterface $call = null
Severity: Minor
Found in src/Phan/Plugin/Internal/ThrowAnalyzerPlugin.php - About 3 hrs 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 computeTypeSetOfMergedArrayShapeTypes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private static function computeTypeSetOfMergedArrayShapeTypes(array $old_type_set, array $new_type_set, int $dim_depth, bool $is_real): array
    {
        if ($is_real) {
            if (!$old_type_set || !$new_type_set) {
                return [];
Severity: Minor
Found in src/Phan/Analysis/AssignmentVisitor.php - About 3 hrs 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 visitCall has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitCall(Node $node): Context
    {
        // Analyze the call to the node, in case it modifies any variables (e.g. count($x = new_value()), if (preg_match(..., $matches), etc.
        // TODO: Limit this to nodes which actually contain variables or properties?
        // TODO: Only call this if the caller is also a ConditionVisitor, since BlockAnalysisVisitor would call this for ternaries and if statements already.
Severity: Minor
Found in src/Phan/Analysis/ConditionVisitor.php - About 3 hrs 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 computeIntOrFloatOperationResult has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public static function computeIntOrFloatOperationResult(
        Node $node,
        UnionType $left,
        UnionType $right
    ): UnionType {
Severity: Minor
Found in src/Phan/Analysis/BinaryOperatorFlagVisitor.php - About 3 hrs 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 parseCodePolyfill has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public static function parseCodePolyfill(CodeBase $code_base, Context $context, string $file_path, string $file_contents, bool $suppress_parse_errors, ?Request $request, array &$errors = []): Node
    {
        // @phan-suppress-next-line PhanRedundantCondition
        if (!\in_array(Config::AST_VERSION, TolerantASTConverter::SUPPORTED_AST_VERSIONS, true)) {
            throw new \Error(\sprintf("Unexpected polyfill version: want %s, got %d", \implode(', ', TolerantASTConverter::SUPPORTED_AST_VERSIONS), Config::AST_VERSION));
Severity: Minor
Found in src/Phan/AST/Parser.php - About 3 hrs 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 analyzeProp has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function analyzeProp(Node $node, bool $is_static): Context
    {
        $exception_or_null = null;

        try {
Severity: Minor
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 3 hrs 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 visitMagicConst has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitMagicConst(Node $node): UnionType
    {
        $flags = $node->flags;
        switch ($flags) {
            case ast\flags\MAGIC_CLASS:
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.php - About 3 hrs 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 checkOpcacheAndReflectionAreConsistent has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkOpcacheAndReflectionAreConsistent(CodeBase $code_base, array $reflection_data, array $opcache_data): void
    {
        foreach ($opcache_data as $function_name => $opcache_type) {
            $reflection_type = $reflection_data[$function_name] ?? null;
            if (!$reflection_type) {
Severity: Minor
Found in internal/extract_arg_info.php - About 3 hrs 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 visitSwitch has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitSwitch(Node $node): void
    {
        // Check all case statements and return if something that isn't a no-op is seen.
        foreach ($node->children['stmts']->children ?? [] as $c) {
            if (!$c instanceof Node) {
Severity: Minor
Found in .phan/plugins/EmptyStatementListPlugin.php - About 3 hrs 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 visitAssign has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitAssign(Node $node): void
    {
        $var = $node->children['var'];
        if (!$var instanceof Node) {
            return;
Severity: Minor
Found in .phan/plugins/RedundantAssignmentPlugin.php - About 3 hrs 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 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function analyzeFunction(
        CodeBase $code_base,
        Func $function
    ): void {
        // NOTE: Placeholders can be found in \Phan\Issue::uncolored_format_string_for_replace
Severity: Minor
Found in .phan/plugins/UnknownElementTypePlugin.php - About 3 hrs 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

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

    File sanitycheck.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env php
    <?php
    
    declare(strict_types=1);
    
    
    Severity: Minor
    Found in internal/sanitycheck.php - About 3 hrs to fix

      Method run has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function run(CodeBase $code_base, Closure $file_path_lister, array $options): ?Request
          {
              if (!$code_base->isUndoTrackingEnabled()) {
                  throw new AssertionError("Expected undo tracking to be enabled");
              }
      Severity: Major
      Found in src/Phan/LanguageServer/LanguageServer.php - About 3 hrs to fix

        Method analyzePropAssignment has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function analyzePropAssignment(Clazz $clazz, Property $property, Node $node): Context
            {
                if ($property->isReadOnly()) {
                    $this->analyzeAssignmentToReadOnlyProperty($property, $node);
                }
        Severity: Major
        Found in src/Phan/Analysis/AssignmentVisitor.php - About 3 hrs to fix

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

              private function checkComplexIsset(Node $node): Context
              {
                  // Loop to support getting the var name in is_array($x['field'][0])
                  $has_prop_access = false;
                  $context = $this->context;
          Severity: Major
          Found in src/Phan/Analysis/ConditionVisitor.php - About 3 hrs to fix
            Severity
            Category
            Status
            Source
            Language