Showing 4,939 of 4,939 total issues

Method maybeParsePhanCustomAnnotation has 134 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function maybeParsePhanCustomAnnotation(int $i, string $line, string $type, string $case_sensitive_type): void
    {
        switch ($type) {
            case 'phan-forbid-undeclared-magic-properties':
                if ($this->checkCompatible('@phan-forbid-undeclared-magic-properties', [Comment::ON_CLASS], $i)) {
Severity: Major
Found in src/Phan/Language/Element/Comment/Builder.php - About 5 hrs to fix

    Method analyzeRealSignatureCompatibility has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function analyzeRealSignatureCompatibility(CodeBase $code_base, FunctionInterface $method, int $minimum_target_php_version): void
        {
            $php70_checks = $minimum_target_php_version < 70100;
    
            foreach ($method->getRealParameterList() as $real_parameter) {
    Severity: Major
    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 5 hrs to fix

      Parameter has 40 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Parameter extends Variable
      {
          public const REFERENCE_DEFAULT = 1;
          public const REFERENCE_READ_WRITE = 2;
          public const REFERENCE_WRITE_ONLY = 3;
      Severity: Minor
      Found in src/Phan/Language/Element/Parameter.php - About 5 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public function visitClassConst(Node $node): void
            {
                $context = $this->context;
                try {
                    $class_fqsen = $context->getClassFQSEN();
        Severity: Major
        Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php and 1 other location - About 5 hrs to fix
        src/Phan/Plugin/Internal/DependencyGraphPlugin.php on lines 682..703

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 190.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public function visitStaticCall(Node $node): void
            {
                $context = $this->context;
                try {
                    $class_fqsen = $context->getClassFQSEN();
        Severity: Major
        Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php and 1 other location - About 5 hrs to fix
        src/Phan/Plugin/Internal/DependencyGraphPlugin.php on lines 654..676

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 190.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method getPropertyByNameInContext has 133 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getPropertyByNameInContext(
                CodeBase $code_base,
                string $name,
                Context $context,
                bool $is_static,
        Severity: Major
        Found in src/Phan/Language/Element/Clazz.php - About 5 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public function asExpandedTypes(
                  CodeBase $code_base,
                  int $recursion_depth = 0
              ): UnionType {
                  // We're going to assume that if the type hierarchy
          Severity: Major
          Found in src/Phan/Language/Type/ArrayShapeType.php and 1 other location - About 5 hrs to fix
          src/Phan/Language/Type/ArrayShapeType.php on lines 678..707

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 189.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public function asExpandedTypesPreservingTemplate(
                  CodeBase $code_base,
                  int $recursion_depth = 0
              ): UnionType {
                  // We're going to assume that if the type hierarchy
          Severity: Major
          Found in src/Phan/Language/Type/ArrayShapeType.php and 1 other location - About 5 hrs to fix
          src/Phan/Language/Type/ArrayShapeType.php on lines 631..660

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 189.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function encodeValue has a Cognitive Complexity of 35 (exceeds 5 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: Minor
          Found in src/Phan/Debug/Frame.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

          Function extractDescriptionFromDocComment has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function extractDescriptionFromDocComment(
                  AddressableElementInterface $element,
                  CodeBase $code_base = null
              ): ?string {
                  $extracted_doc_comment = self::extractDescriptionFromDocCommentRaw($element);
          Severity: Minor
          Found in src/Phan/Language/Element/MarkupDescription.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

          Function combineScopeList has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              public function combineScopeList(array $scope_list): Context
              {
                  if (\count($scope_list) < 2) {
                      throw new AssertionError("Expected at least two child contexts in " . __METHOD__);
                  }
          Severity: Minor
          Found in src/Phan/Analysis/ContextMergeVisitor.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

          Function resolveArrayShapeElementTypes has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              private function resolveArrayShapeElementTypes(Node $node, UnionType $union_type): ?UnionType
              {
                  $dim_node = $node->children['dim'];
                  $dim_value = $dim_node instanceof Node ? (new ContextNode($this->code_base, $this->context, $dim_node))->getEquivalentPHPScalarValue() : $dim_node;
                  // TODO: detect and warn about null
          Severity: Minor
          Found in src/Phan/AST/UnionTypeVisitor.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

          Function visitStmtList has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              public function visitStmtList(Node $node): void
              {
                  if (count($node->children) <= 1) {
                      return;
                  }
          Severity: Minor
          Found in .phan/plugins/DuplicateConstantPlugin.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 PropertyMap.php has 383 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Function renderLongProgress has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function renderLongProgress(string $msg, float $p, float $memory, ?int $offset, ?int $count): string
                {
                    $buf = '';
                    if ($msg !== self::$current_progress_state_long_progress) {
                        switch ($msg) {
            Severity: Minor
            Found in src/Phan/CLI.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

            Function createPhanSettingsForComposerSettings has a Cognitive Complexity of 34 (exceeds 5 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: Minor
            Found in src/Phan/Config/Initializer.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

            Function analyzeGenericArrayAssignment has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                private function analyzeGenericArrayAssignment(Node $node): void
                {
                    // Figure out the type of elements in the list
                    $right_type = $this->right_type;
                    if ($right_type->isEmpty()) {
            Severity: Minor
            Found in src/Phan/Analysis/AssignmentVisitor.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

            Function checkComplexIsset has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                private function checkComplexIsset(Node $node): Context
                {
                    // Loop to support getting the var name in is_array($x['field'][0])
                    $has_prop_access = false;
                    $context = $this->context;
            Severity: Minor
            Found in src/Phan/Analysis/ConditionVisitor.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

            Function findNodeAtOffsetRecursive has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function findNodeAtOffsetRecursive(\Microsoft\PhpParser\Node $parser_node, int $offset)
                {
                    foreach ($parser_node->getChildNodesAndTokens() as $key => $node_or_token) {
                        if ($node_or_token instanceof Token) {
                            // fprintf(

            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 analyzeReturnTypesInner has 127 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function analyzeReturnTypesInner(CodeBase $code_base): void
                {
                    if ($this->isPHPInternal()) {
                        // nothing to do, no known Node
                        return;
            Severity: Major
            Found in src/Phan/Language/Element/FunctionTrait.php - About 5 hrs to fix
              Severity
              Category
              Status
              Source
              Language