Showing 3,272 of 4,939 total issues

Method resolveDocCommentForClosure has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function resolveDocCommentForClosure(PhpParser\Node\Expression $node): ?string
    {
        $doc_comment = $node->getDocCommentText();
        if (\Phan\Library\StringUtil::isNonZeroLengthString($doc_comment)) {
            return $doc_comment;
Severity: Major
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php - About 2 hrs to fix

    File PregRegexCheckerPlugin.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    use ast\Node;
    Severity: Minor
    Found in .phan/plugins/PregRegexCheckerPlugin.php - About 2 hrs to fix

      Method finalizeAnalyzingURIs has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function finalizeAnalyzingURIs(): void
          {
              [$uris_to_analyze, $file_path_list] = $this->getFilteredURIsToAnalyze();
              // TODO: Add a better abstraction of
              if (\count($uris_to_analyze) === 0) {
      Severity: Major
      Found in src/Phan/LanguageServer/LanguageServer.php - About 2 hrs to fix

        Method analyze has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method analyzeMethod has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function analyzeMethod(
                  CodeBase $code_base,
                  Method $method
              ): void {
                  if ($method->getFQSEN() !== $method->getRealDefiningFQSEN()) {
          Severity: Major
          Found in .phan/plugins/UnknownElementTypePlugin.php - About 2 hrs to fix

            Request has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Request
            {
                public const METHOD_ANALYZE_FILES = 'analyze_files';  // has shorthand analyze_file with param 'file'
            
                public const PARAM_METHOD = 'method';
            Severity: Minor
            Found in src/Phan/Daemon/Request.php - About 2 hrs to fix

              GlobalScope has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              final class GlobalScope extends Scope
              {
                  /**
                   * Deliberate no-op
                   */
              Severity: Minor
              Found in src/Phan/Language/Scope/GlobalScope.php - About 2 hrs to fix

                File InvokePHPNativeSyntaxCheckPlugin.php has 277 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                declare(strict_types=1);
                
                use ast\Node;
                Severity: Minor
                Found in .phan/plugins/InvokePHPNativeSyntaxCheckPlugin.php - About 2 hrs to fix

                  Method orderForProcessCount has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function orderForProcessCount(
                          int $process_count,
                          array $analysis_file_list
                      ): array {
                  
                  
                  Severity: Major
                  Found in src/Phan/Ordering.php - About 2 hrs to fix

                    Method removeTruthyFromVariable has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        final protected function removeTruthyFromVariable(Node $var_node, Context $context, bool $suppress_issues, bool $check_empty): Context
                        {
                            return $this->updateVariableWithConditionalFilter(
                                $var_node,
                                $context,
                    Severity: Major
                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 2 hrs to fix

                      Method resolveArrayShapeElementTypes has 66 lines of code (exceeds 25 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: Major
                      Found in src/Phan/AST/UnionTypeVisitor.php - About 2 hrs to fix

                        Method getElementsFromElementListForDeferredAnalysis has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private static function getElementsFromElementListForDeferredAnalysis(
                                CodeBase $code_base,
                                iterable $element_list,
                                int $total_count,
                                int &$i
                        Severity: Major
                        Found in src/Phan/Analysis/ReferenceCountsAnalyzer.php - About 2 hrs to fix

                          Method analyzeProp has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function analyzeProp(Node $node, bool $is_static): Context
                              {
                                  $exception_or_null = null;
                          
                                  try {
                          Severity: Major
                          Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 2 hrs to fix

                            Method analyzeCallToFunctionLike has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function analyzeCallToFunctionLike(
                                    FunctionInterface $method,
                                    Node $node
                                ): void {
                                    $code_base = $this->code_base;
                            Severity: Major
                            Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 2 hrs to fix

                              Method resolveArrayShapeElementTypesForOffset has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function resolveArrayShapeElementTypesForOffset(UnionType $union_type, $dim_value, bool $is_computing_real_type_set = false)
                                  {
                                      /**
                                       * @var bool $has_non_array_shape_type this will be true if there are types that support array access
                                       *           but have unknown array shapes in $union_type
                              Severity: Major
                              Found in src/Phan/AST/UnionTypeVisitor.php - About 2 hrs to fix

                                Method methodFQSENListFromObjectAndMethodName has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private function methodFQSENListFromObjectAndMethodName($class_or_expr, string $method_name): array
                                    {
                                        $code_base = $this->code_base;
                                        $context = $this->context;
                                
                                
                                Severity: Major
                                Found in src/Phan/AST/UnionTypeVisitor.php - About 2 hrs to fix

                                  Function orderForProcessCount has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function orderForProcessCount(
                                          int $process_count,
                                          array $analysis_file_list
                                      ): array {
                                  
                                  
                                  Severity: Minor
                                  Found in src/Phan/Ordering.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 importMixin has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function importMixin(CodeBase $code_base, Type $type): void
                                      {
                                          $fqsen = FullyQualifiedClassName::fromType($type);
                                          if (!$code_base->hasClassWithFQSEN($fqsen) || $fqsen === $this->fqsen) {
                                              Issue::maybeEmit(
                                  Severity: Minor
                                  Found in src/Phan/Language/Element/Clazz.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 canCastToNonNullableType has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function canCastToNonNullableType(Type $type): bool
                                      {
                                          if ($type instanceof ScalarType) {
                                              switch ($type::NAME) {
                                                  case 'int':
                                  Severity: Minor
                                  Found in src/Phan/Language/Type/NonZeroIntType.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 canStrictCastToUnionType has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function canStrictCastToUnionType(CodeBase $code_base, UnionType $target): bool
                                      {
                                          // Fast-track most common cases first
                                          $type_set = $this->type_set;
                                          // If either type is unknown, we can't call it
                                  Severity: Minor
                                  Found in src/Phan/Language/UnionType.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language