Showing 3,272 of 4,939 total issues

Method encodeValue has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function encodeValue($value, int $max_depth = 2): string
    {
        if (is_object($value)) {
            if ($value instanceof IssueInstance) {
                return "IssueInstance($value)";
Severity: Major
Found in src/Phan/Debug/Frame.php - About 2 hrs to fix

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

        public static function fromNode(
            Context $context,
            CodeBase $code_base,
            Node $node
        ): Parameter {
    Severity: Major
    Found in src/Phan/Language/Element/Parameter.php - About 2 hrs to fix

      Method createSwitchConditionAnalyzer has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function createSwitchConditionAnalyzer($switch_case_node): array
          {
              $switch_kind = ($switch_case_node->kind ?? null);
              try {
                  if ($switch_kind === ast\AST_VAR) {
      Severity: Major
      Found in src/Phan/BlockAnalysisVisitor.php - About 2 hrs to fix

        Method analyzeClassConstantTypes has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function analyzeClassConstantTypes(CodeBase $code_base, Clazz $clazz): void
            {
                foreach ($clazz->getConstantMap($code_base) as $constant) {
                    // This phase is done before the analysis phase, so there aren't any dynamic properties to filter out.
        
        
        Severity: Major
        Found in src/Phan/Analysis/ClassConstantTypesAnalyzer.php - About 2 hrs to fix

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

            Method visitMagicConst has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function visitMagicConst(Node $node): UnionType
                {
                    $flags = $node->flags;
                    switch ($flags) {
                        case ast\flags\MAGIC_CLASS:
            Severity: Major
            Found in src/Phan/AST/UnionTypeVisitor.php - About 2 hrs to fix

              Method phpParserTypeToAstNode has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected static function phpParserTypeToAstNode($type, int $line): ?ast\Node
                  {
                      if (\is_null($type)) {
                          return null;
                      }
              Severity: Major
              Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php - About 2 hrs to fix

                Method handleTraitPrecedence has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function handleTraitPrecedence(array $adaptations_map, Node $adaptation_node): void
                    {
                        // TODO: Should also verify that the original method exists, in a future PR?
                        $trait_method_node = $adaptation_node->children['method'];
                        if (!$trait_method_node instanceof Node) {
                Severity: Major
                Found in src/Phan/AST/ContextNode.php - About 2 hrs to fix

                  Method dump_main has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function dump_main(): void
                  {
                      $print_help = static function (int $exit_code): void {
                          global $argv;
                          $help = <<<"EOB"
                  Severity: Major
                  Found in internal/dump_fallback_ast.php - About 2 hrs to fix

                    Method astNodeToPrimitive has 69 lines of code (exceeds 25 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: Major
                    Found in .phan/plugins/PrintfCheckerPlugin.php - About 2 hrs to fix

                      Function finalizeAnalyzingURIs has a Cognitive Complexity of 20 (exceeds 5 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: Minor
                      Found in src/Phan/LanguageServer/LanguageServer.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 extractParamTagsFromDocComment has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function extractParamTagsFromDocComment(AddressableElementInterface $element, bool $with_param_details = true): array
                          {
                              $doc_comment = $element->getDocComment();
                              if (!\is_string($doc_comment)) {
                                  return [];
                      Severity: Minor
                      Found in src/Phan/Language/Element/MarkupDescription.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 __construct has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function __construct(
                              int $comment_flags,
                              array $variable_list,
                              array $parameter_list,
                              array $template_type_list,
                      Severity: Minor
                      Found in src/Phan/Language/Element/Comment.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 20 (exceeds 5 allowed). Consider refactoring.
                      Open

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

                          public static function getKeyTypeOfArrayNode(CodeBase $code_base, Context $context, Node $node, bool $should_catch_issue_exception = true): int
                          {
                              $key_type_enum = GenericArrayType::KEY_EMPTY;
                              // Check the all elements for key types.
                              foreach ($node->children as $child) {
                      Severity: Minor
                      Found in src/Phan/Language/Type/GenericArrayType.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 canCastToGenericArrayKeys has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function canCastToGenericArrayKeys(GenericArrayType $type, bool $ignore_config = false): bool
                          {
                              if ($type instanceof ListType) {
                                  $i = 0;
                                  $has_possibly_undefined = false;
                      Severity: Minor
                      Found in src/Phan/Language/Type/ArrayShapeType.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 withFlattenedArrayShapeTypeInstancesForSet has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private static function withFlattenedArrayShapeTypeInstancesForSet(array $type_set): array
                          {
                              $result = [];
                              $has_other_array_type = false;
                              $empty_array_shape_type = null;
                      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

                      Function canCastToNonNullableType has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

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

                          public function hasSubtypeOf(
                              UnionType $target
                          ): bool {
                              // Fast-track most common cases first
                              $type_set = $this->type_set;
                      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

                      Function visitForeach has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function visitForeach(Node $node): Context
                          {
                              $code_base = $this->code_base;
                              $context = $this->context;
                              $context->setLineNumberStart($node->lineno);
                      Severity: Minor
                      Found in src/Phan/BlockAnalysisVisitor.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