Showing 3,272 of 4,939 total issues

Function finalizeProcess has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function finalizeProcess(CodeBase $code_base): void
    {
        if (empty($this->elements)) {
            \fwrite(\STDERR, "Nothing to analyze - please run pdep from your top-level project directory" . \PHP_EOL);
            exit(\EXIT_FAILURE);
Severity: Minor
Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php - About 5 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 visitVar has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitVar(Node $node): Context
    {
        try {
            $variable_name = (new ContextNode(
                $this->code_base,
Severity: Minor
Found in src/Phan/Analysis/AssignmentVisitor.php - About 5 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 visitStmtList has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitStmtList(Node $node): void
    {
        $child_nodes = $node->children;

        $last_node_index = count($child_nodes) - 1;
Severity: Minor
Found in .phan/plugins/UnreachableCodePlugin.php - About 5 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 checkCall has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkCall(FunctionInterface $function, array $args, Node $node): void
    {
        $arg_names = [];
        foreach ($args as $i => $arg_node) {
            $name = self::extractName($arg_node);
Severity: Minor
Found in .phan/plugins/SuspiciousParamOrderPlugin.php - About 5 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 isRedundantFunctionComment has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    private static function isRedundantFunctionComment(FunctionInterface $method, string $doc_comment): bool
    {
        $lines = explode("\n", $doc_comment);
        foreach ($lines as $line) {
            $line = trim($line, " \r\n\t*/");
Severity: Minor
Found in .phan/plugins/PHPDocRedundantPlugin.php - About 5 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 hasInternalFunctionWithFQSEN has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    private function hasInternalFunctionWithFQSEN(
        FullyQualifiedFunctionName $fqsen
    ): bool {
        $canonical_fqsen = $fqsen->withAlternateId(0);
        $found = isset($this->internal_function_fqsen_set[$canonical_fqsen]);
Severity: Minor
Found in src/Phan/CodeBase.php - About 5 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 checkInvalidArrayShapeCombination has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    public static function checkInvalidArrayShapeCombination(
        CodeBase $code_base,
        Context $context,
        Node $node,
        UnionType $left,
Severity: Minor
Found in src/Phan/Analysis/BinaryOperatorFlagVisitor.php - About 5 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 createClosureForMethod has 135 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function createClosureForMethod(CodeBase $code_base, Method $method, string $name): ?Closure
    {
        // TODO: Add a helper method which will convert a doc comment and a stub php function source code to a closure for a param index (or indices)
        switch (\strtolower($name)) {
            case 'asserttrue':
Severity: Major
Found in .phan/plugins/PHPUnitAssertionPlugin.php - About 5 hrs to fix

    File ReferenceCountsAnalyzer.php has 391 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    namespace Phan\Analysis;
    Severity: Minor
    Found in src/Phan/Analysis/ReferenceCountsAnalyzer.php - About 5 hrs to fix

      Method maybeParsePhanCustomAnnotation has 134 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function maybeParsePhanCustomAnnotation(int $i, string $line, string $type, string $case_sensitive_type): void
          {
              switch ($type) {
                  case 'phan-forbid-undeclared-magic-properties':
                      if ($this->checkCompatible('@phan-forbid-undeclared-magic-properties', [Comment::ON_CLASS], $i)) {
      Severity: Major
      Found in src/Phan/Language/Element/Comment/Builder.php - About 5 hrs to fix

        Method analyzeRealSignatureCompatibility has 134 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function analyzeRealSignatureCompatibility(CodeBase $code_base, FunctionInterface $method, int $minimum_target_php_version): void
            {
                $php70_checks = $minimum_target_php_version < 70100;
        
                foreach ($method->getRealParameterList() as $real_parameter) {
        Severity: Major
        Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 5 hrs to fix

          Parameter has 40 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Parameter extends Variable
          {
              public const REFERENCE_DEFAULT = 1;
              public const REFERENCE_READ_WRITE = 2;
              public const REFERENCE_WRITE_ONLY = 3;
          Severity: Minor
          Found in src/Phan/Language/Element/Parameter.php - About 5 hrs to fix

            Method getPropertyByNameInContext has 133 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getPropertyByNameInContext(
                    CodeBase $code_base,
                    string $name,
                    Context $context,
                    bool $is_static,
            Severity: Major
            Found in src/Phan/Language/Element/Clazz.php - About 5 hrs to fix

              Function encodeValue has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function encodeValue($value, int $max_depth = 2): string
                  {
                      if (is_object($value)) {
                          if ($value instanceof IssueInstance) {
                              return "IssueInstance($value)";
              Severity: Minor
              Found in src/Phan/Debug/Frame.php - About 5 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 extractDescriptionFromDocComment has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function extractDescriptionFromDocComment(
                      AddressableElementInterface $element,
                      CodeBase $code_base = null
                  ): ?string {
                      $extracted_doc_comment = self::extractDescriptionFromDocCommentRaw($element);
              Severity: Minor
              Found in src/Phan/Language/Element/MarkupDescription.php - About 5 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 combineScopeList has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function combineScopeList(array $scope_list): Context
                  {
                      if (\count($scope_list) < 2) {
                          throw new AssertionError("Expected at least two child contexts in " . __METHOD__);
                      }
              Severity: Minor
              Found in src/Phan/Analysis/ContextMergeVisitor.php - About 5 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 resolveArrayShapeElementTypes has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function resolveArrayShapeElementTypes(Node $node, UnionType $union_type): ?UnionType
                  {
                      $dim_node = $node->children['dim'];
                      $dim_value = $dim_node instanceof Node ? (new ContextNode($this->code_base, $this->context, $dim_node))->getEquivalentPHPScalarValue() : $dim_node;
                      // TODO: detect and warn about null
              Severity: Minor
              Found in src/Phan/AST/UnionTypeVisitor.php - About 5 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 visitStmtList has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function visitStmtList(Node $node): void
                  {
                      if (count($node->children) <= 1) {
                          return;
                      }
              Severity: Minor
              Found in .phan/plugins/DuplicateConstantPlugin.php - About 5 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

              File PropertyMap.php has 383 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              declare(strict_types=1);
              
              namespace Phan\Language\Internal;
              Severity: Minor
              Found in src/Phan/Language/Internal/PropertyMap.php - About 5 hrs to fix

                Function renderLongProgress has a Cognitive Complexity of 34 (exceeds 5 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: Minor
                Found in src/Phan/CLI.php - About 5 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

                Severity
                Category
                Status
                Source
                Language