Showing 4,939 of 4,939 total issues

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

    final protected function removeLiteralScalarFromVariable(
        Node $var_node,
        Context $context,
        $value,
        bool $strict_equality
Severity: Minor
Found in src/Phan/Analysis/ConditionVisitorUtil.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 analyzeReturnInGenerator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function analyzeReturnInGenerator(
        FunctionInterface $method,
        Node $node
    ): void {
        $method_generator_type = $method->getReturnTypeAsGeneratorTemplateType();
Severity: Minor
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.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 checkPassingPropertyByReference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkPassingPropertyByReference(CodeBase $code_base, Context $context, FunctionInterface $method, Parameter $parameter, Node $argument, Property $property, int $parameter_offset): void
    {
        $parameter_type = $parameter->getNonVariadicUnionType();
        $expr_node = $argument->children['expr'] ?? null;
        if ($expr_node instanceof Node &&
Severity: Minor
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.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 createConverter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function createConverter(string $file_path, string $file_contents, Request $request = null): TolerantASTConverter
    {
        if ($request) {
            if ($request->shouldUseMappingPolyfill($file_path)) {
                // TODO: Rename to something better
Severity: Minor
Found in src/Phan/AST/Parser.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 print has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function print(IssueInstance $instance): void
    {
        $issue = $instance->getIssue();
        $message = HTML::htmlTemplate(
            $issue->getTemplateRaw(),
Severity: Minor
Found in src/Phan/Output/Printer/HTMLPrinter.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 flush has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function flush(): void
    {
        $document = new \DOMDocument('1.0', 'ISO-8859-15');

        $checkstyle = new \DOMElement('checkstyle');
Severity: Minor
Found in src/Phan/Output/Printer/CheckstylePrinter.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 visitClassConst has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitClassConst(Node $node): UnionType
    {
        $class_node = $node->children['class'];
        if (!$class_node instanceof Node || $class_node->kind !== ast\AST_NAME) {
            // ignore nonsense like (0)::class, and dynamic accesses such as $var::CLASS
Severity: Minor
Found in src/Phan/AST/FallbackUnionTypeVisitor.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 visitClassNameNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function visitClassNameNode(Node $node): ?UnionType
    {
        // Things of the form `new $className()`, `new $obj()`, `new (foo())()`, etc.
        if ($node->kind !== \ast\AST_NAME) {
            return null;
Severity: Minor
Found in src/Phan/AST/FallbackUnionTypeVisitor.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 dumpTreeAsString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function dumpTreeAsString($ast_node, string $key = '', string $padding = ''): string
    {
        if ($ast_node instanceof Node) {
            $first_part = \sprintf(
                "%s%s%s%s\n",
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/NodeDumper.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 phpParserMatchArmListToAstMatchArmList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function phpParserMatchArmListToAstMatchArmList(?\Microsoft\PhpParser\Node\DelimitedList\MatchExpressionArmList $arms, int $start_line): ast\Node
    {
        $ast_arms = [];
        foreach ($arms->children ?? [] as $arm) {
            if (!$arm instanceof PhpParser\Node\MatchArm) {
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.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 visitCall has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitCall(Node $node): UnionType
    {
        $expression = $node->children['expr'];
        if (!($expression instanceof Node && $expression->kind === ast\AST_NAME)) {
            // Give up on closures, callables
Severity: Minor
Found in src/Phan/AST/FallbackUnionTypeVisitor.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 phpParserMatchConditionListToAstNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function phpParserMatchConditionListToAstNode(?PhpParser\Node\DelimitedList\MatchArmConditionList $condition_list): ?ast\Node
    {
        if (!$condition_list) {
            throw new InvalidNodeException();
        }
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.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 phpParserNamespaceUseListToAstUseList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function phpParserNamespaceUseListToAstUseList(array $uses): array
    {
        $ast_uses = [];
        foreach ($uses as $use_clause) {
            if (!($use_clause instanceof PhpParser\Node\NamespaceUseGroupClause)) {
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.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 applyToScopeInner has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function applyToScopeInner($node): void
    {
        if ($node instanceof Node) {
            $kind = $node->kind;
            if (\in_array($kind, self::SCOPE_START_LIST, true)) {
Severity: Minor
Found in src/Phan/AST/PhanAnnotationAdder.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 visitCall has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitCall(Node $node): UnionType
    {
        $expression = $node->children['expr'];
        $function_list_generator = (new ContextNode(
            $this->code_base,
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.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 visitClassConst has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitClassConst(Node $node): UnionType
    {
        try {
            $constant = (new ContextNode(
                $this->code_base,
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.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 unionTypeFromNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function unionTypeFromNode(
        CodeBase $code_base,
        Context $context,
        $node,
        bool $should_catch_issue_exception = true
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.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 handleTraitAlias has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function handleTraitAlias(array $adaptations_map, Node $adaptation_node): void
    {
        $trait_method_node = $adaptation_node->children['method'];
        if (!$trait_method_node instanceof Node) {
            throw new AssertionError("Expected node for trait alias");
Severity: Minor
Found in src/Phan/AST/ContextNode.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 resolveClassNameInContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolveClassNameInContext(): ?FullyQualifiedClassName
    {
        // A function argument to resolve into an FQSEN
        $arg = $this->node;

Severity: Minor
Found in src/Phan/AST/ContextNode.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 getPhanSignatureArrayFromReflection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function getPhanSignatureArrayFromReflection(ReflectionFunctionAbstract $function): array
{
    $return_type = $function->getReturnType();
    $return_type_representation = getUnionTypeStringForReflectionType($return_type);
    $result = [0 => $return_type_representation];
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

Severity
Category
Status
Source
Language