Showing 3,272 of 4,939 total issues

Function getClassList has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    public function getClassList(
        bool $ignore_missing_classes = false,
        int $expected_type_categories = self::CLASS_LIST_ACCEPT_ANY,
        string $custom_issue_type = null,
        bool $warn_if_wrong_type = true
Severity: Minor
Found in src/Phan/AST/ContextNode.php - About 6 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 getMethod has 156 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getMethod(
        $method_name,
        bool $is_static,
        bool $is_direct = false,
        bool $is_new_expression = false
Severity: Major
Found in src/Phan/AST/ContextNode.php - About 6 hrs to fix

    IncompatibleXMLSignatureDetector has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class IncompatibleXMLSignatureDetector extends IncompatibleSignatureDetectorBase
    {
        use Memoize;
    
        /** @var string the directory for english PHP element references */
    Severity: Minor
    Found in internal/lib/IncompatibleXMLSignatureDetector.php - About 6 hrs to fix

      Function analyzeFileList has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function analyzeFileList(
              CodeBase $code_base,
              Closure $file_path_lister
          ): bool {
              if (Config::getValue('dump_parsed_file_list') === true) {
      Severity: Minor
      Found in src/Phan/Phan.php - About 6 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 visitClosure has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          public function visitClosure(Node $node): Context
          {
              $code_base = $this->code_base;
              $context = $this->context->withoutLoops();
              $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext(
      Severity: Minor
      Found in src/Phan/Analysis/PreOrderAnalysisVisitor.php - About 6 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 DuplicateExpressionPlugin.php has 418 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

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

        Builder has 44 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class Builder
        {
            /** @var string the original raw comment */
            public $comment;
            /** @var list<string> the list of lines of the doc comment */
        Severity: Minor
        Found in src/Phan/Language/Element/Comment/Builder.php - About 6 hrs to fix

          ParseVisitor has 44 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ParseVisitor extends ScopeVisitor
          {
          
              /**
               * @param Context $context
          Severity: Minor
          Found in src/Phan/Parse/ParseVisitor.php - About 6 hrs to fix

            File Comment.php has 416 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

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

              Method getFlagInfo has 148 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function getFlagInfo(): array
                  {
                      // TODO: Use AST's built in flag info if available.
                      static $exclusive, $combinable;
                      // Write this in a way that lets Phan infer the value of $combinable at the end.
              Severity: Major
              Found in src/Phan/Debug.php - About 5 hrs to fix

                Function parseCommentLine has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function parseCommentLine(int $i, string $line): void
                    {
                        // https://secure.php.net/manual/en/regexp.reference.internal-options.php
                        // (?i) makes this case-sensitive, (?-1) makes it case-insensitive
                        // phpcs:ignore Generic.Files.LineLength.MaxExceeded
                Severity: Minor
                Found in src/Phan/Language/Element/Comment/Builder.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 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

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