Showing 3,272 of 4,939 total issues

Method fromNode has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function fromNode(
        Context $context,
        CodeBase $code_base,
        Node $node,
        FullyQualifiedMethodName $fqsen,
Severity: Major
Found in src/Phan/Language/Element/Method.php - About 3 hrs to fix

    Method visitProp has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function visitProp(Node $node): Context
        {
            // Get class list first, warn if the class list is invalid.
            try {
                $class_list = (new ContextNode(
    Severity: Major
    Found in src/Phan/Analysis/AssignmentVisitor.php - About 3 hrs to fix

      Method visitBinaryAdd has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function visitBinaryAdd(Node $node): UnionType
          {
              $code_base = $this->code_base;
              $context = $this->context;
              $left = UnionTypeVisitor::unionTypeFromNode(
      Severity: Major
      Found in src/Phan/Analysis/BinaryOperatorFlagVisitor.php - About 3 hrs to fix

        Method getConst has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getConst(): GlobalConstant
            {
                $node = $this->node;
                if (!$node instanceof Node) {
                    throw new AssertionError('$node must be a node');
        Severity: Major
        Found in src/Phan/AST/ContextNode.php - About 3 hrs to fix

          File GoToDefinitionRequest.php has 306 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            IssueFixSuggester has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class IssueFixSuggester
            {
                /** @see https://www.php.net/levenshtein - levenshtein warns and returns -1 for longer strings */
                private const MAX_SUGGESTION_NAME_LENGTH = 255;
            
            
            Severity: Minor
            Found in src/Phan/IssueFixSuggester.php - About 3 hrs to fix

              Method fromInternalTypeName has 83 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function fromInternalTypeName(
                      string $type_name,
                      bool $is_nullable,
                      int $source,
                      array $template_parameter_type_list = []
              Severity: Major
              Found in src/Phan/Language/Type.php - About 3 hrs to fix

                Method analyzeComposition has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function analyzeComposition(
                        CodeBase $code_base,
                        Clazz $class
                    ): void {
                        // Get the list of all inherited classes.
                Severity: Major
                Found in src/Phan/Analysis/CompositionAnalyzer.php - About 3 hrs to fix

                  Method getAnalyzeFunctionCallClosures has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getAnalyzeFunctionCallClosures(CodeBase $code_base): array
                      {
                          /**
                           * @param list<Node|string|int|float> $args the nodes for the arguments to the invocation
                           */
                  Severity: Major
                  Found in .phan/plugins/PregRegexCheckerPlugin.php - About 3 hrs to fix

                    File MethodSearcherPlugin.php has 304 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

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

                      Method addConstant has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function addConstant(
                              CodeBase $code_base,
                              Context $context,
                              int $lineno,
                              string $name,
                      Severity: Major
                      Found in src/Phan/Parse/ParseVisitor.php - About 3 hrs to fix

                        Function getFlagSuggestionString has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function getFlagSuggestionString(
                                string $key
                            ): string {
                                $trim = static function (string $s): string {
                                    return \rtrim($s, ':');
                        Severity: Minor
                        Found in src/Phan/CLI.php - About 3 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 finishAnalyzingRemainingStatements has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function finishAnalyzingRemainingStatements(
                                CodeBase $code_base,
                                ?Request $request,
                                array $analyze_file_path_list,
                                array $temporary_file_mapping
                        Severity: Minor
                        Found in src/Phan/Phan.php - About 3 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 fromFullyQualifiedStringInner has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected static function fromFullyQualifiedStringInner(
                                string $fully_qualified_string
                            ): Type {
                                if ($fully_qualified_string === '') {
                                    throw new InvalidArgumentException("Type cannot be empty");
                        Severity: Minor
                        Found in src/Phan/Language/Type.php - About 3 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 createMatchConditionAnalyzer has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function createMatchConditionAnalyzer($match_case_node): array
                            {
                                $match_kind = ($match_case_node->kind ?? null);
                                try {
                                    if ($match_kind === ast\AST_VAR) {
                        Severity: Minor
                        Found in src/Phan/BlockAnalysisVisitor.php - About 3 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 phan_error_handler has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function phan_error_handler(int $errno, string $errstr, string $errfile, int $errline): bool
                        {
                            global $__no_echo_phan_errors;
                            if ($__no_echo_phan_errors) {
                                if ($__no_echo_phan_errors instanceof Closure) {
                        Severity: Minor
                        Found in src/Phan/Bootstrap.php - About 3 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 visitClassConstDecl has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function visitClassConstDecl(Node $node): Context
                            {
                                $class = $this->getContextClass();
                        
                                foreach ($node->children as $child_node) {
                        Severity: Minor
                        Found in src/Phan/Parse/ParseVisitor.php - About 3 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 checkForInvalidNewType has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function checkForInvalidNewType(Node $node, array $class_list): void
                            {
                                // This is either a string (new 'something'()) or a class name (new something())
                                $class_node = $node->children['class'];
                                if (!$class_node instanceof Node) {
                        Severity: Minor
                        Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 3 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 load has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function load(): void
                            {
                                if (!class_exists('\ast\Node')) {
                                    // Fix for https://github.com/phan/phan/issues/2287
                                    require_once __DIR__ . '/ast_shim.php';
                        Severity: Minor
                        Found in src/Phan/AST/TolerantASTConverter/Shim.php - About 3 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 unionTypeFromClassNode has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function unionTypeFromClassNode(
                                CodeBase $code_base,
                                Context $context,
                                $node
                            ): UnionType {
                        Severity: Minor
                        Found in src/Phan/AST/UnionTypeVisitor.php - About 3 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