Showing 4,939 of 4,939 total issues

File FallbackUnionTypeVisitor.php has 411 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Phan\AST;
Severity: Minor
Found in src/Phan/AST/FallbackUnionTypeVisitor.php - About 5 hrs to fix

    GenericArrayType has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

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

      BlockExitStatusChecker has 43 functions (exceeds 20 allowed). Consider refactoring.
      Open

      final class BlockExitStatusChecker extends KindVisitorImplementation
      {
          // These should be at most 1 << 31, in order to work in 32-bit php.
          // NOTE: Any exit status must be a combination of at least one of these bits
          // E.g. if STATUS_PROCEED is mixed with STATUS_RETURN, it would mean it is possible both to go to completion or return.
      Severity: Minor
      Found in src/Phan/Analysis/BlockExitStatusChecker.php - About 5 hrs to fix

        Method analyzeParameterList has 144 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function analyzeParameterList(
                CodeBase $code_base,
                FunctionInterface $method,
                Node $node,
                Context $context
        Severity: Major
        Found in src/Phan/Analysis/ArgumentType.php - About 5 hrs to fix

          Function astNodeToPrimitive has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function astNodeToPrimitive(CodeBase $code_base, Context $context, $ast_node): ?PrimitiveValue
              {
                  // Base case: convert primitive tokens such as numbers and strings.
                  if (!($ast_node instanceof Node)) {
                      return new PrimitiveValue($ast_node);
          Severity: Minor
          Found in .phan/plugins/PrintfCheckerPlugin.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 analyzeParameterTypesInner has 143 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function analyzeParameterTypesInner(
                  CodeBase $code_base,
                  FunctionInterface $method
              ): void {
                  if (Config::getValue('check_docblock_signature_param_type_match')) {
          Severity: Major
          Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 5 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public static function fromElementType(
                    Type $type,
                    bool $is_nullable,
                    int $key_type = GenericArrayType::KEY_INT
                ): GenericArrayType {
            Severity: Major
            Found in src/Phan/Language/Type/NonEmptyAssociativeArrayType.php and 1 other location - About 5 hrs to fix
            src/Phan/Language/Type/AssociativeArrayType.php on lines 23..53

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 198.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public static function fromElementType(
                    Type $type,
                    bool $is_nullable,
                    int $key_type = GenericArrayType::KEY_MIXED
                ): GenericArrayType {
            Severity: Major
            Found in src/Phan/Language/Type/AssociativeArrayType.php and 1 other location - About 5 hrs to fix
            src/Phan/Language/Type/NonEmptyAssociativeArrayType.php on lines 21..51

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 198.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method has 42 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Method extends ClassElement implements FunctionInterface
            {
                use Analyzable;
                use Memoize;
                use FunctionTrait;
            Severity: Minor
            Found in src/Phan/Language/Element/Method.php - About 5 hrs to fix

              File CompletionResolver.php has 400 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

                Method createPhanSettingsForComposerSettings has 140 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function createPhanSettingsForComposerSettings(array $composer_settings, ?string $vendor_path, array $opts): InitializedSettings
                    {
                        $level = $opts['init-level'] ?? 3;
                        $level = self::LEVEL_MAP[\strtolower((string)$level)] ?? $level;
                        if (\filter_var($level, FILTER_VALIDATE_INT) === false) {
                Severity: Major
                Found in src/Phan/Config/Initializer.php - About 5 hrs to fix

                  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
                      Severity
                      Category
                      Status
                      Source
                      Language