Showing 3,272 of 4,939 total issues

Function setValue has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public static function setValue(string $name, $value): void
    {
        self::$configuration[$name] = $value;
        switch ($name) {
            case 'ignore_undeclared_functions_with_known_signatures':
Severity: Minor
Found in src/Phan/Config.php - About 2 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 computeIssueSuppressionList has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private static function computeIssueSuppressionList(
        string $file_contents
    ): array {
        if (!\preg_match(self::SUPPRESS_ISSUE_REGEX, $file_contents)) {
            // If the **file** doesn't contain the regex we're looking for,
Severity: Minor
Found in src/Phan/Plugin/Internal/BuiltinSuppressionPlugin.php - About 2 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 dumpGraphML has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function dumpGraphML(string $title, array $graph, bool $is_classgraph, bool $hide_labels): void
    {
        $node_id = 0;
        $edge_id = 0;

Severity: Minor
Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php - About 2 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 visitDim has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitDim(Node $node): Context
    {
        if (!Config::get_backward_compatibility_checks()) {
            return $this->context;
        }
Severity: Minor
Found in src/Phan/Parse/ParseVisitor.php - About 2 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 updateTargetDimWithType has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function updateTargetDimWithType(Node $assign_op_node, Closure $get_type): Context
    {
        $node = $assign_op_node->children['var'];
        if (!$node instanceof Node) {
            // Should be impossible as currently called, but warn anyway.
Severity: Minor
Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 2 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 updateVariableToBeNotEqual has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    final public function updateVariableToBeNotEqual(
        Node $var_node,
        $expr,
        Context $context = null
    ): Context {
Severity: Minor
Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 2 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 visitBinaryAdd has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitBinaryAdd(Node $node): UnionType
    {
        $code_base = $this->code_base;
        $context = $this->context;
        $left = UnionTypeVisitor::unionTypeFromNode(
Severity: Minor
Found in src/Phan/Analysis/BinaryOperatorFlagVisitor.php - About 2 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 createArrayShapeType has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function createArrayShapeType(array $key_set): ArrayShapeType
    {
        $field_types = [];

        foreach ($key_set as $key => $child) {
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.php - About 2 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 visitTypeUnion has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitTypeUnion(Node $node): UnionType
    {
        // TODO: Validate that there aren't any duplicates
        if (\count($node->children) === 1) {
            // Might be possible due to the polyfill in the future.
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.php - About 2 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 getEquivalentArraySet has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function getEquivalentArraySet(Node $node): ?array
    {
        $elements = [];
        $context_node = null;
        foreach ($node->children as $child_node) {
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.php - About 2 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 findEndLine has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function findEndLine(int $lineno, Node $search_node): int
    {
        for ($node_index = count($this->parent_node_list) - 1; $node_index >= 0; $node_index--) {
            $node = $this->parent_node_list[$node_index] ?? null;
            if (!$node) {
Severity: Minor
Found in .phan/plugins/EmptyStatementListPlugin.php - About 2 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 analyzeReturnValue has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function analyzeReturnValue($expr_node, int $lineno, array &$sleep_properties): void
    {
        $context = clone($this->context)->withLineNumberStart($lineno);
        if (!($expr_node instanceof Node)) {
            $this->emitPluginIssue(
Severity: Minor
Found in .phan/plugins/SleepCheckerPlugin.php - About 2 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

Method renderLongProgress has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function renderLongProgress(string $msg, float $p, float $memory, ?int $offset, ?int $count): string
    {
        $buf = '';
        if ($msg !== self::$current_progress_state_long_progress) {
            switch ($msg) {
Severity: Major
Found in src/Phan/CLI.php - About 2 hrs to fix

    Method phan_repl_help has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function phan_repl_help($value = "\x00extended_help"): void
    {
        if ($value === "\x00extended_help") {
            echo "Phan " . CLI::PHAN_VERSION . " CLI autocompletion utilities.\n";
            echo "Type help(\$value); or help('function or constant or class name'); for help.\n";
    Severity: Major
    Found in tool/phan_repl_helpers.php - About 2 hrs to fix

      Method visitWhile has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function visitWhile(Node $node): Context
          {
              $context = $this->context->withLineNumberStart(
                  $node->lineno
              )->withEnterLoop($node);
      Severity: Major
      Found in src/Phan/BlockAnalysisVisitor.php - About 2 hrs to fix

        Method extractIncrementDirections has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function extractIncrementDirections(CodeBase $code_base, Context $context, $cond_node): array
            {
                if (!$cond_node instanceof Node) {
                    return [];
                }
        Severity: Major
        Found in src/Phan/Plugin/Internal/RedundantConditionLoopCheck.php - About 2 hrs to fix

          Method updateTargetDimWithType has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function updateTargetDimWithType(Node $assign_op_node, Closure $get_type): Context
              {
                  $node = $assign_op_node->children['var'];
                  if (!$node instanceof Node) {
                      // Should be impossible as currently called, but warn anyway.
          Severity: Major
          Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 2 hrs to fix

            LanguageServer has 25 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class LanguageServer extends AdvancedJsonRpc\Dispatcher
            {
                /**
                 * Handles workspace/* method calls
                 *
            Severity: Minor
            Found in src/Phan/LanguageServer/LanguageServer.php - About 2 hrs to fix

              ArrayType has 25 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class ArrayType extends IterableType
              {
                  /** @phan-override */
                  public const NAME = 'array';
              
              
              Severity: Minor
              Found in src/Phan/Language/Type/ArrayType.php - About 2 hrs to fix

                NegatedConditionVisitor has 25 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class NegatedConditionVisitor extends KindVisitorImplementation implements ConditionVisitorInterface
                {
                    // TODO: if (a || b || c || d) might get really slow, due to creating both ConditionVisitor and NegatedConditionVisitor
                    use ConditionVisitorUtil;
                
                
                Severity: Minor
                Found in src/Phan/Analysis/NegatedConditionVisitor.php - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language