Showing 3,272 of 4,939 total issues

Method guessErrorColumnUsingTokens has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function guessErrorColumnUsingTokens(
        FileCacheEntry $file_cache_entry,
        Error $native_parse_error
    ): int {
        if (!\function_exists('token_get_all')) {
Severity: Minor
Found in src/Phan/AST/Parser.php - About 2 hrs to fix

    Method analyzeIncOrDec has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function analyzeIncOrDec(Node $node): Context
        {
            $var = $node->children['var'];
            $old_type = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $var);
            if (!$old_type->canCastToUnionType(UnionType::fromFullyQualifiedPHPDocString('int|string|float'))) {
    Severity: Minor
    Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if ((
                      (
                          $lnode->children['prop'] instanceof Node
                          && $lnode->children['prop']->kind === ast\AST_VAR
                      )
      Severity: Critical
      Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

        Method getClassListInner has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getClassListInner(bool $ignore_missing_classes): array
            {
                $node = $this->node;
                if (!($node instanceof Node)) {
                    if (\is_string($node)) {
        Severity: Minor
        Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

          Method recordHoverTextForElementType has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function recordHoverTextForElementType(
                  CodeBase $code_base,
                  Context $context,
                  TypedElementInterface $element
              ): void {
          Severity: Minor
          Found in src/Phan/LanguageServer/GoToDefinitionRequest.php - About 1 hr to fix

            Method readMessages has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function readMessages(): int
                {
                    $emitted_messages = 0;
                    while (($c = \fgetc($this->input)) !== false && $c !== '') {
                        $this->buffer .= $c;
            Severity: Minor
            Found in src/Phan/LanguageServer/ProtocolStreamReader.php - About 1 hr to fix

              Method analyzeBinaryBitwiseCommon has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function analyzeBinaryBitwiseCommon(Node $node): UnionType
                  {
                      $left = UnionTypeVisitor::unionTypeFromNode(
                          $this->code_base,
                          $this->context,
              Severity: Minor
              Found in src/Phan/Analysis/BinaryOperatorFlagVisitor.php - About 1 hr to fix

                Method phpParserStmtlistToAstNode has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function phpParserStmtlistToAstNode($parser_nodes, ?int $lineno, bool $return_null_on_empty = false): ?\ast\Node
                    {
                        if ($parser_nodes instanceof PhpParser\Node\Statement\CompoundStatementNode) {
                            $parser_nodes = $parser_nodes->statements;
                        } elseif ($parser_nodes instanceof PhpParser\Node\StatementNode) {
                Severity: Minor
                Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php - About 1 hr to fix

                  Method visitNew has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function visitNew(Node $node): UnionType
                      {
                          static $object_type;
                          if ($object_type === null) {
                              $object_type = ObjectType::instance(false);
                  Severity: Minor
                  Found in src/Phan/AST/UnionTypeVisitor.php - About 1 hr to fix

                    Method extractUnionType has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static function extractUnionType(array $flags): UnionType
                        {
                            static $type_lookup = null;
                            if ($type_lookup === null) {
                                $type_lookup = [
                    Severity: Minor
                    Found in internal/extract_arg_info.php - About 1 hr to fix

                      Method makeIfLoaded has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function makeIfLoaded(string $namespace, string $name)
                          {
                              $name_parts = \explode('\\', $name);
                              $name = (string)\array_pop($name_parts);
                              if ($name === '') {
                      Severity: Minor
                      Found in src/Phan/Language/FQSEN/FullyQualifiedGlobalStructuralElement.php - About 1 hr to fix

                        Method parseGenericArrayTypeFromTemplateParameterList has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private static function parseGenericArrayTypeFromTemplateParameterList(
                                array $template_parameter_type_list,
                                bool $is_nullable,
                                bool $always_has_elements,
                                bool $is_associative
                        Severity: Minor
                        Found in src/Phan/Language/Type.php - About 1 hr to fix

                          Method analyzeNumericArithmeticOp has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function analyzeNumericArithmeticOp(Node $node, bool $combination_is_int): Context
                              {
                                  return $this->updateTargetWithType($node, function (UnionType $left) use ($node, $combination_is_int): UnionType {
                                      $code_base = $this->code_base;
                                      $context = $this->context;
                          Severity: Minor
                          Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 1 hr to fix

                            Method analyzeClassInheritance has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function analyzeClassInheritance(
                                    CodeBase $code_base,
                                    Clazz $clazz
                                ): void {
                            
                            
                            Severity: Minor
                            Found in src/Phan/Analysis/ClassInheritanceAnalyzer.php - About 1 hr to fix

                              Method tryToAssignPHPDocTypeToParameter has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private static function tryToAssignPHPDocTypeToParameter(
                                      CodeBase $code_base,
                                      FunctionInterface $method,
                                      int $i,
                                      Parameter $parameter,
                              Severity: Minor
                              Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 1 hr to fix

                                Method compareNamedParameters has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static function compareNamedParameters(): void
                                    {
                                        if (PHP_MAJOR_VERSION < 8) {
                                            fwrite(STDERR, "compare-named-parameters MUST BE RUN IN PHP 8.0+, BUT WAS RUN IN " . PHP_VERSION . "\n");
                                            fwrite(STDERR, "exiting without generating stubs\n");
                                Severity: Minor
                                Found in internal/lib/IncompatibleXMLSignatureDetector.php - About 1 hr to fix

                                  Method visitVar has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function visitVar(Node $node): void
                                      {
                                          // @phan-suppress-next-line PhanUndeclaredProperty
                                          if ($node->flags & PhanAnnotationAdder::FLAG_INITIALIZES || isset($node->is_reference)) {
                                              return;
                                  Severity: Minor
                                  Found in .phan/plugins/ConstantVariablePlugin.php - About 1 hr to fix

                                    Function exportFunctionAndMethodSet has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function exportFunctionAndMethodSet(): array
                                        {
                                            $result = [];
                                            foreach ($this->getFunctionAndMethodSet() as $function_or_method) {
                                                if ($function_or_method->isPHPInternal()) {
                                    Severity: Minor
                                    Found in src/Phan/CodeBase.php - About 1 hr 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 recordTypeOfElement has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        private function recordTypeOfElement(
                                            CodeBase $code_base,
                                            Context $context,
                                            TypedElementInterface $element
                                        ): void {
                                    Severity: Minor
                                    Found in src/Phan/LanguageServer/GoToDefinitionRequest.php - About 1 hr 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 fromReflectionParameter has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public static function fromReflectionParameter(
                                            \ReflectionParameter $reflection_parameter
                                        ): Parameter {
                                            $flags = 0;
                                            // Check to see if it's a pass-by-reference parameter
                                    Severity: Minor
                                    Found in src/Phan/Language/Element/Parameter.php - About 1 hr 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