Showing 3,272 of 4,939 total issues

Function getReturnTypes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getReturnTypes(Context $context, $node, int $return_lineno): \Generator
    {
        if (!($node instanceof Node)) {
            if (null === $node) {
                yield $return_lineno => [VoidType::instance(false)->asRealUnionType(), null];
Severity: Minor
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 55 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 computeStatusOfSwitchList has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function computeStatusOfSwitchList(Node $node): int
    {
        $switch_stmt_case_nodes = $node->children ?? [];
        if (\count($switch_stmt_case_nodes) === 0) {
            return self::STATUS_PROCEED;
Severity: Minor
Found in src/Phan/Analysis/BlockExitStatusChecker.php - About 55 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 updateVariableWithConditionalFilter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    final protected function updateVariableWithConditionalFilter(
        Node $var_node,
        Context $context,
        Closure $should_filter_cb,
        Closure $filter_union_type_cb,
Severity: Minor
Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 55 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 handleParseError has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function handleParseError(
        CodeBase $code_base,
        Context $context,
        string $file_path,
        string $file_contents,
Severity: Minor
Found in src/Phan/AST/Parser.php - About 55 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 checkForInfiniteRecursion has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkForInfiniteRecursion(Node $node, FunctionInterface $method): void
    {
        $argument_list_node = $node->children['args'];
        $kind = $node->kind;
        if ($kind === ast\AST_METHOD_CALL || $kind === ast\AST_NULLSAFE_METHOD_CALL) {
Severity: Minor
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 55 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 warnOverridingFinalMethod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private static function warnOverridingFinalMethod(CodeBase $code_base, Method $method, Clazz $class, Method $o_method): void
    {
        if ($method->isFromPHPDoc()) {
            // TODO: Track phpdoc methods separately from real methods
            if ($class->checkHasSuppressIssueAndIncrementCount(Issue::AccessOverridesFinalMethodPHPDoc)) {
Severity: Minor
Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 55 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 visitConstDecl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitConstDecl(Node $node): Context
    {
        foreach ($node->children as $child_node) {
            if (!$child_node instanceof Node) {
                throw new AssertionError('expected const element to be a Node');
Severity: Minor
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 55 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 getPrinter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPrinter(?string $type, OutputInterface $output): IssuePrinterInterface
    {
        switch ($type) {
            case 'codeclimate':
                $printer = new CodeClimatePrinter();
Severity: Minor
Found in src/Phan/Output/PrinterFactory.php - About 55 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 interfaceBaseClauseToNode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private static function interfaceBaseClauseToNode(?\Microsoft\PhpParser\Node\InterfaceBaseClause $node): ?\ast\Node
    {
        if (!$node instanceof PhpParser\Node\InterfaceBaseClause) {
            // TODO: real placeholder?
            return null;
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php - About 55 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 visitStaticCall has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitStaticCall(Node $node): UnionType
    {
        ['class' => $class_node, 'method' => $method_name] = $node->children;
        if (!\is_string($method_name) || !($class_node instanceof Node) || $class_node->kind !== ast\AST_NAME) {
            // Give up on dynamic calls
Severity: Minor
Found in src/Phan/AST/FallbackUnionTypeVisitor.php - About 55 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 normalizeStatementList has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private static function normalizeStatementList(array $statements): array
    {
        $modified = false;
        $new_statements = [];
        foreach ($statements as $stmt) {
Severity: Minor
Found in src/Phan/AST/ASTSimplifier.php - About 55 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 visitClassNameNode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function visitClassNameNode(Node $node): UnionType
    {
        $kind = $node->kind;
        // Anonymous class of form `new class { ... }`
        if ($kind === \ast\AST_CLASS
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.php - About 55 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 unionTypeFromLiteralOrConstant has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function unionTypeFromLiteralOrConstant(CodeBase $code_base, Context $context, $node): ?UnionType
    {
        if ($node instanceof Node) {
            // TODO: There are a lot more types of expressions that have known union types that this doesn't handle.
            // Maybe callers should call something else if this fails (e.g. it's useful for them to know if an expression becomes a string)
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.php - About 55 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 getTraitAdaptationsMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getTraitAdaptationsMap(array $trait_fqsen_list): array
    {
        if (!($this->node instanceof Node)) {
            return [];
        }
Severity: Minor
Found in src/Phan/AST/ContextNode.php - About 55 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 getVariableStrict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getVariableStrict(): Variable
    {
        $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 55 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 getFunctionLikeFromDynamicExpression has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function getFunctionLikeFromDynamicExpression(): \Generator
    {
        $code_base = $this->code_base;
        $context = $this->context;
        $expression = $this->node;
Severity: Minor
Found in src/Phan/AST/ContextNode.php - About 55 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 getLinesToDelete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getLinesToDelete(string $file_contents): array
    {
        $paths = [];
        foreach (explode("\n", $file_contents) as $line) {
            $line = trim($line);
Severity: Minor
Found in internal/line_deleter.php - About 55 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 generateCssForColor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function generateCssForColor(string $color): string
    {
        $combination = [];
        foreach (explode(',', $color) as $color_component) {
            if ($color_component === 'none') {
Severity: Minor
Found in internal/dump_html_styles.php - About 55 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 computeEditSetToDeleteComment has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private static function computeEditSetToDeleteComment(string $file_contents, Token $comment_token): FileEditSet
    {
        // get the byte where the `)` of the argument list ends
        $last_byte_index = $comment_token->getEndPosition();
        $first_byte_index = $comment_token->start;
Severity: Minor
Found in .phan/plugins/PHPDocRedundantPlugin/Fixers.php - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAnalyzeFunctionCallClosures(CodeBase $code_base): array
    {
        $warn_remove_debug_call = static function (CodeBase $code_base, Context $context, FunctionInterface $function): void {
            self::emitIssue(
                $code_base,
Severity: Minor
Found in .phan/plugins/RemoveDebugStatementPlugin.php - About 55 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