Showing 3,272 of 4,939 total issues

Method visitConditional has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function visitConditional(Node $node): UnionType
    {
        $cond_node = $node->children['cond'];
        $cond_truthiness = self::checkCondUnconditionalTruthiness($cond_node);
        // For the shorthand $a ?: $b, the cond node will be the truthy value.
Severity: Major
Found in src/Phan/AST/UnionTypeVisitor.php - About 3 hrs to fix

    Method unionTypeFromClassNode has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function unionTypeFromClassNode(
            CodeBase $code_base,
            Context $context,
            $node
        ): UnionType {
    Severity: Major
    Found in src/Phan/AST/UnionTypeVisitor.php - About 3 hrs to fix

      File Func.php has 324 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/Func.php - About 3 hrs to fix

        Method functionListFromFunction has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function functionListFromFunction(
                FunctionInterface $function
            ): array {
                // See if we have any type information for this
                // internal function
        Severity: Major
        Found in src/Phan/Language/Element/FunctionFactory.php - About 3 hrs to fix

          Function accept has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function accept(CodeBase $code_base, Closure $file_path_lister, Responder $responder, bool $fork): ?Request
              {
                  FileCache::clear();
          
                  $request = $responder->getRequestData();
          Severity: Minor
          Found in src/Phan/Daemon/Request.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 recordHoverTextForElementType has a Cognitive Complexity of 26 (exceeds 5 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 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 canCastToNonNullableType has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function canCastToNonNullableType(Type $type): bool
              {
                  if ($type instanceof ArrayType) {
                      if ($type instanceof GenericArrayType) {
                          return $this->canCastToGenericArrayKeys($type) &&
          Severity: Minor
          Found in src/Phan/Language/Type/ArrayShapeType.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 canCastToNonNullableTypeWithoutConfig has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function canCastToNonNullableTypeWithoutConfig(Type $type): bool
              {
                  if ($type instanceof ArrayType) {
                      if ($type instanceof GenericArrayType) {
                          // TODO: WithoutConfig here as well?
          Severity: Minor
          Found in src/Phan/Language/Type/ArrayShapeType.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 canCastToUnionTypeHandlingTemplates has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              public function canCastToUnionTypeHandlingTemplates(
                  UnionType $target,
                  CodeBase $code_base
              ): bool {
                  // Fast-track most common cases first
          Severity: Minor
          Found in src/Phan/Language/UnionType.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 analyzeSubstituteVarAssert has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              private function analyzeSubstituteVarAssert(CodeBase $code_base, Context $context, string $text): void
              {
                  $has_known_annotations = false;
                  if (\preg_match_all(self::PHAN_VAR_REGEX, $text, $matches, \PREG_SET_ORDER) > 0) {
                      $has_known_annotations = true;
          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 getReturnTypeOverridesStatic has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function getReturnTypeOverridesStatic(): array
              {
                  /**
                   * @param list<Node|int|string|float> $args
                   */
          Severity: Minor
          Found in src/Phan/Plugin/Internal/ClosureReturnTypeOverridePlugin.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 calculateNarrowedUnionType has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function calculateNarrowedUnionType(CodeBase $code_base, Context $context, UnionType $old_type, UnionType $asserted_object_type): UnionType
              {
                  $new_type_set = [];
                  foreach ($old_type->getTypeSet() as $type) {
                      if ($type instanceof MixedType) {
          Severity: Minor
          Found in src/Phan/Analysis/ConditionVisitor.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 visitArgList has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              public function visitArgList(Node $node): Context
              {
                  $argument_name_set = [];
                  $has_unpack = false;
          
          
          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 inheritPHPDoc has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function inheritPHPDoc(
                  CodeBase $code_base,
                  Method $method,
                  Method $o_method
              ): void {
          Severity: Minor
          Found in src/Phan/Analysis/ParameterTypesAnalyzer.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 analyzeReturnStrict has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              private function analyzeReturnStrict(
                  CodeBase $code_base,
                  FunctionInterface $method,
                  UnionType $expression_type,
                  UnionType $method_return_type,
          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 analyzeProp has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              private function analyzeProp(Node $node, bool $is_static): UnionType
              {
                  // Either expr(instance) or class(static) is set
                  $expr_node = $node->children['expr'] ?? null;
                  try {
          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

          File GenericIterableType.php has 322 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Method visitClass has 93 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function visitClass(Node $node): Context
                {
                    if ($node->flags & \ast\flags\CLASS_ANONYMOUS) {
                        $class_name = (new ContextNode(
                            $this->code_base,
            Severity: Major
            Found in src/Phan/Parse/ParseVisitor.php - About 3 hrs to fix

              ConditionVisitor has 30 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class ConditionVisitor extends KindVisitorImplementation implements ConditionVisitorInterface
              {
                  use ConditionVisitorUtil;
              
                  /** @internal */
              Severity: Minor
              Found in src/Phan/Analysis/ConditionVisitor.php - About 3 hrs to fix

                Method visitClassConstDecl has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function visitClassConstDecl(Node $node): Context
                    {
                        $class = $this->getContextClass();
                
                        foreach ($node->children as $child_node) {
                Severity: Major
                Found in src/Phan/Parse/ParseVisitor.php - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language