Showing 3,272 of 4,939 total issues

Function visitBinaryOp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitBinaryOp(Node $node): Context
    {
        // get the types of left and right values
        $left_node = $node->children['left'];
        $left_type = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $left_node);
Severity: Minor
Found in .phan/plugins/NumericalComparisonPlugin.php - About 45 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 visitReturn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitReturn(Node $node): void
    {
        if (!$this->context->isInFunctionLikeScope()) {
            return;
        }
Severity: Minor
Found in .phan/plugins/MoreSpecificElementTypePlugin.php - About 45 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 computeEditsForParamTypeDeclaration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private static function computeEditsForParamTypeDeclaration(FileCacheEntry $contents, FunctionLike $declaration, string $param_name, string $param_type): ?FileEditSet
    {
        if ($param_type === '') {
            return null;
        }
Severity: Minor
Found in .phan/plugins/PHPDocToRealTypesPlugin/Fixers.php - About 45 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 beforeAnalyzePhase has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function beforeAnalyzePhase(CodeBase $code_base): void
    {
        $ignore_overrides = (bool)getenv('PHPDOC_TO_REAL_TYPES_IGNORE_INHERITANCE');
        foreach ($this->deferred_analysis_methods as $method) {
            if ($method->isOverride() || $method->isOverriddenByAnother()) {
Severity: Minor
Found in .phan/plugins/PHPDocToRealTypesPlugin.php - About 45 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 determineShorterType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private static function determineShorterType(Context $context, Node $type_node): ?string
    {
        if ($type_node->kind !== ast\AST_NAME) {
            return null;
        }
Severity: Minor
Found in .phan/plugins/PreferNamespaceUsePlugin.php - About 45 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 generateInstanceObjectCompletions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateInstanceObjectCompletions(array $tokens): array
    {
        $i = count($tokens) - 1;
        $this->appendToLogFile("generateInstanceObjectCompletions tokens = " . StringUtil::jsonEncode($tokens) . "\n");
        while (!is_array($tokens[$i]) || $tokens[$i][0] !== T_OBJECT_OPERATOR) {
Severity: Minor
Found in tool/phan_repl_helpers.php - About 45 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 analyzeStatementsOfSleep has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function analyzeStatementsOfSleep($node, array &$sleep_properties = []): void
    {
        if (!($node instanceof Node)) {
            if (is_array($node)) {
                foreach ($node as $child_node) {
Severity: Minor
Found in .phan/plugins/SleepCheckerPlugin.php - About 45 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 extractIfElseifChain has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private static function extractIfElseifChain(Node $node): array
    {
        $children = $node->children;
        if (count($children) <= 1) {
            return $children;
Severity: Minor
Found in .phan/plugins/DuplicateExpressionPlugin.php - About 45 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 checkForSuspiciousRegexPatterns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkForSuspiciousRegexPatterns(string $pattern): Generator
    {
        $pattern = \trim($pattern);

        $start_chr = $pattern[0] ?? '/';
Severity: Minor
Found in .phan/plugins/PregRegexCheckerPlugin.php - About 45 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 visitConditional has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitConditional(Node $node): void
    {
        $cond_node = $node->children['cond'];
        $true_node_hash = ASTHasher::hash($node->children['true']);

Severity: Minor
Found in .phan/plugins/DuplicateExpressionPlugin.php - About 45 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

Consider simplifying this complex logical expression.
Open

                if ($this instanceof Func || ($this instanceof Method && ($this->isPrivate() || $this->isEffectivelyFinal() || $this->isMagicAndVoid() || $this->getClass($code_base)->isFinal()))) {
                    $this->setUnionType(VoidType::instance(false)->asPHPDocUnionType());
                }
Severity: Major
Found in src/Phan/Language/Element/FunctionTrait.php - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

            if (Config::getValue('unused_variable_detection') &&
                !$expression_union_type->isEmpty() && !$expression_union_type->hasPossiblyObjectTypes() &&
                InferPureSnippetVisitor::isSideEffectFreeSnippet($this->code_base, $inner_context, $stmts_node) &&
                self::isLoopVariableWithoutSideEffects($node->children['key']) &&
                self::isLoopVariableWithoutSideEffects($node->children['value'])
    Severity: Major
    Found in src/Phan/BlockAnalysisVisitor.php - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

                      if ($o_real_parameter !== null && $real_parameter !== null && !$real_parameter->getUnionType()->isEmptyOrMixed() && $o_real_parameter->getUnionType()->isEmptyOrMixed()
                          && (!$method->isFromPHPDoc() || $parameter->getUnionType()->isEmptyOrMixed())) {
                          $signatures_match = false;
                          $mismatch_details = "Cannot use $parameter with a real type to override parameter $o_parameter without a real type";
                          break;
      Severity: Major
      Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 40 mins to fix

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

                string $msg,
                float $p,
                $details = null,
                ?int $offset = null,
                ?int $count = null
        Severity: Minor
        Found in src/Phan/CLI.php - About 35 mins to fix

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

              public function __construct(string $message = null, Range $range = null, int $code = null, int $severity = null, string $source = null)
          Severity: Minor
          Found in src/Phan/LanguageServer/Protocol/Diagnostic.php - About 35 mins to fix

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

                    CompletionRequest $request,
                    CodeBase $code_base,
                    Context $context,
                    Node $node,
                    string $incomplete_constant_name
            Severity: Minor
            Found in src/Phan/LanguageServer/CompletionResolver.php - About 35 mins to fix

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

                      CompletionRequest $request,
                      CodeBase $code_base,
                      Context $context,
                      Node $node,
                      $constant_name
              Severity: Minor
              Found in src/Phan/LanguageServer/CompletionResolver.php - About 35 mins to fix

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

                        array $internal_class_name_list,
                        array $internal_interface_name_list,
                        array $internal_trait_name_list,
                        array $internal_constant_name_list,
                        array $internal_function_name_list
                Severity: Minor
                Found in src/Phan/CodeBase.php - About 35 mins to fix

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

                      private static function renderLongProgress(string $msg, float $p, float $memory, ?int $offset, ?int $count): string
                  Severity: Minor
                  Found in src/Phan/CLI.php - About 35 mins to fix

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

                            CompletionRequest $request,
                            CodeBase $code_base,
                            Context $context,
                            Node $node,
                            string $incomplete_class_name
                    Severity: Minor
                    Found in src/Phan/LanguageServer/CompletionResolver.php - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language