Showing 3,272 of 4,939 total issues

Function addClosureForDependentTemplateType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function addClosureForDependentTemplateType(CodeBase $code_base, Context $context, array $template_type_list): void
    {
        if ($this->hasDependentReturnType()) {
            // We already added this or this conflicts with a plugin.
            return;
Severity: Minor
Found in src/Phan/Language/Element/FunctionTrait.php - About 1 hr 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 getOverriddenMethods has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getOverriddenMethods(
        CodeBase $code_base
    ): array {
        // Get the class that defines this method
        $class = $this->getClass($code_base);
Severity: Minor
Found in src/Phan/Language/Element/Method.php - About 1 hr 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 withExitLoop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function withExitLoop(Node $node): Context
    {
        $context = clone($this);

        while ($context->loop_nodes) {
Severity: Minor
Found in src/Phan/Language/Context.php - About 1 hr 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 hasSuppressIssue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function hasSuppressIssue(
        CodeBase $code_base,
        string $issue_name
    ): bool {
        if ($code_base->hasFileLevelSuppression($this->file, $issue_name)) {
Severity: Minor
Found in src/Phan/Language/Context.php - About 1 hr 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 warnAboutUnusedUseElements has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function warnAboutUnusedUseElements(CodeBase $code_base): void
    {
        foreach ($this->namespace_map as $flags => $entries_for_flag) {
            foreach ($entries_for_flag as $namespace_map_entry) {
                if ($namespace_map_entry->is_used) {
Severity: Minor
Found in src/Phan/Language/Context.php - About 1 hr 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 ofUnique has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function ofUnique(array $type_list, array $real_type_set = []): UnionType
    {
        $n = \count($type_list);
        if ($n === 0) {
            if ($real_type_set) {
Severity: Minor
Found in src/Phan/Language/UnionType.php - About 1 hr 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 canPossiblyCastToClass has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function canPossiblyCastToClass(CodeBase $code_base, Type $other): bool
    {
        if (!$this->isPossiblyObject()) {
            return false;
        }
Severity: Minor
Found in src/Phan/Language/Type.php - About 1 hr 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 getTemplateTypeExtractorClosure has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getTemplateTypeExtractorClosure(CodeBase $code_base, TemplateType $template_type): ?Closure
    {
        if (!$this->template_parameter_type_list) {
            return null;
        }
Severity: Minor
Found in src/Phan/Language/Type.php - About 1 hr 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 shapeComponentStringsToTypes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function shapeComponentStringsToTypes(array $shape_components, Context $context, int $source, CodeBase $code_base = null): array
    {
        $result = [];
        foreach ($shape_components as $key => $component_string) {
            if (\is_string($key) && \strpos($key, '\\') !== false) {
Severity: Minor
Found in src/Phan/Language/Type.php - About 1 hr 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 canCastToTypeHandlingTemplates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function canCastToTypeHandlingTemplates(Type $type, CodeBase $code_base): bool
    {
        // Check to see if we have an exact object match
        if ($this === $type) {
            return true;
Severity: Minor
Found in src/Phan/Language/Type.php - About 1 hr 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 joinQuotedStrings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function joinQuotedStrings(array $results): array
    {
        // Preserve the original count: This will change if results are combined.
        $N = count($results);
        // Iterate by offset (manually) to avoid unexpected behavior of unset of subsequent elements in foreach
Severity: Minor
Found in src/Phan/Language/Type.php - About 1 hr 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 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitConditional(Node $node): Context
    {
        $context = $this->context->withLineNumberStart(
            $node->lineno
        );
Severity: Minor
Found in src/Phan/BlockAnalysisVisitor.php - About 1 hr 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 nodeToString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function nodeToString(
        $node,
        $name = null,
        int $indent = 0
    ): string {
Severity: Minor
Found in src/Phan/Debug.php - About 1 hr 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 isMatchingNamespaceUseDeclaration has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function isMatchingNamespaceUseDeclaration(
        string $file_contents,
        NamespaceUseDeclaration $declaration,
        IssueInstance $issue_instance
    ): bool {
Severity: Minor
Found in src/Phan/Plugin/Internal/IssueFixingPlugin/IssueFixer.php - About 1 hr 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 definitionInsideNodeHasUseOutsideNode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function definitionInsideNodeHasUseOutsideNode(array $combined_def_uses, Node $loop_node): bool
    {
        if (!$combined_def_uses) {
            return false;
        }
Severity: Minor
Found in src/Phan/Plugin/Internal/VariableTrackerPlugin.php - About 1 hr 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 formatFlags has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function formatFlags(int $kind, int $flags): string
    {
        [$exclusive, $combinable] = self::getFlagInfo();
        if (isset($exclusive[$kind])) {
            $flag_info = $exclusive[$kind];
Severity: Minor
Found in src/Phan/Debug.php - About 1 hr 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 yieldSuppressionCommentsOld has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function yieldSuppressionCommentsOld(
        string $file_contents
    ): Generator {
        foreach (\token_get_all($file_contents) as $token) {
            if (!\is_array($token)) {
Severity: Minor
Found in src/Phan/Plugin/Internal/BuiltinSuppressionPlugin.php - About 1 hr 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 readResultsFromChildren has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function readResultsFromChildren(): array
    {
        // Create an array of all active streams, indexed by
        // resource id.
        $streams = [];
Severity: Minor
Found in src/Phan/ForkPool.php - About 1 hr 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 matchesParamTypes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function matchesParamTypes(CodeBase $code_base, array $search_param_types, array $signature_param_types): float
    {
        if (\count($search_param_types) === 0) {
            // Award extra points for having the same number of matches
            return \max(1, 5 - count($signature_param_types)) / 2;
Severity: Minor
Found in src/Phan/Plugin/Internal/MethodSearcherPlugin.php - About 1 hr 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 extractComparisonDirectionsFromBinaryOp has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function extractComparisonDirectionsFromBinaryOp(Node $cond_node, bool $negate): array
    {
        ['left' => $left_node, 'right' => $right_node] = $cond_node->children;
        switch ($cond_node->flags) {
            case flags\BINARY_IS_SMALLER:
Severity: Minor
Found in src/Phan/Plugin/Internal/RedundantConditionLoopCheck.php - About 1 hr 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