Showing 4,939 of 4,939 total issues

File FunctionSignatureMap_php80_delta.php has 883 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php // phpcs:ignoreFile

/**
 * This contains the information needed to convert the function signatures for php 8.0 to php 7.4 (and vice versa)
 *
Severity: Major
Found in src/Phan/Language/Internal/FunctionSignatureMap_php80_delta.php - About 2 days to fix

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

                if ($match_kind === ast\AST_VAR) {
                    $match_variable = (new ConditionVisitor($this->code_base, $this->context))->getVariableFromScope($match_case_node, $this->context);
                    if (!$match_variable) {
                        return self::NOOP_SWITCH_COND_ANALYZER;
                    }
    Severity: Major
    Found in src/Phan/BlockAnalysisVisitor.php and 1 other location - About 2 days to fix
    src/Phan/BlockAnalysisVisitor.php on lines 1698..1752

    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 433.

    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

                if ($switch_kind === ast\AST_VAR) {
                    $switch_variable = (new ConditionVisitor($this->code_base, $this->context))->getVariableFromScope($switch_case_node, $this->context);
                    if (!$switch_variable) {
                        return self::NOOP_SWITCH_COND_ANALYZER;
                    }
    Severity: Major
    Found in src/Phan/BlockAnalysisVisitor.php and 1 other location - About 2 days to fix
    src/Phan/BlockAnalysisVisitor.php on lines 2292..2346

    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 433.

    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

    File IncompatibleXMLSignatureDetector.php has 878 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    use Phan\Config;
    Severity: Major
    Found in internal/lib/IncompatibleXMLSignatureDetector.php - About 2 days to fix

      CodeBase has 110 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CodeBase
      {
          /**
           * @var Map<FullyQualifiedClassName,Clazz>
           * A map from FQSEN to an internal or user defined class
      Severity: Major
      Found in src/Phan/CodeBase.php - About 2 days to fix

        FunctionLikeDeclarationType has 110 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class FunctionLikeDeclarationType extends Type implements FunctionInterface
        {
            // Subclasses will override this
            public const NAME = '';
        
        
        Severity: Major
        Found in src/Phan/Language/Type/FunctionLikeDeclarationType.php - About 2 days to fix

          File EmptyUnionType.php has 865 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          declare(strict_types=1);
          
          namespace Phan\Language;
          Severity: Major
          Found in src/Phan/Language/EmptyUnionType.php - About 2 days to fix

            KindVisitorImplementation has 107 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class KindVisitorImplementation implements KindVisitor
            {
            
                /**
                 * The fallback implementation for node kinds where the subclass visitor
            Severity: Major
            Found in src/Phan/AST/Visitor/KindVisitorImplementation.php - About 2 days to fix

              File UseReturnValuePlugin.php has 823 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              declare(strict_types=1);
              
              namespace Phan\Plugin\Internal;
              Severity: Major
              Found in src/Phan/Plugin/Internal/UseReturnValuePlugin.php - About 1 day to fix

                Function processGraph has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function processGraph(array $cached_graph = null): void
                    {
                        $cmd  = $_ENV['PDEP_CMD'];
                        $mode = $_ENV['PDEP_MODE'];
                        $this->depth = (int)$_ENV['PDEP_DEPTH'];
                Severity: Minor
                Found in src/Phan/Plugin/Internal/DependencyGraphPlugin.php - About 1 day 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 ConditionVisitor.php has 801 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                declare(strict_types=1);
                
                namespace Phan\Analysis;
                Severity: Major
                Found in src/Phan/Analysis/ConditionVisitor.php - About 1 day to fix

                  Method init has 378 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function init(): void
                      {
                          self::$noop = static function (Node $_): string {
                              return '(unknown)';
                          };
                  Severity: Major
                  Found in src/Phan/AST/ASTReverter.php - About 1 day to fix

                    File VariableTrackerVisitor.php has 761 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    declare(strict_types=1);
                    
                    namespace Phan\Plugin\Internal\VariableTracker;
                    Severity: Major
                    Found in src/Phan/Plugin/Internal/VariableTracker/VariableTrackerVisitor.php - About 1 day to fix

                      Function analyzeParameterList has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private static function analyzeParameterList(
                              CodeBase $code_base,
                              FunctionInterface $method,
                              Node $node,
                              Context $context
                      Severity: Minor
                      Found in src/Phan/Analysis/ArgumentType.php - About 1 day 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 ArrayShapeType.php has 741 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      
                      declare(strict_types=1);
                      
                      namespace Phan\Language\Type;
                      Severity: Major
                      Found in src/Phan/Language/Type/ArrayShapeType.php - About 1 day to fix

                        UnionTypeVisitor has 90 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        class UnionTypeVisitor extends AnalysisVisitor
                        {
                            /**
                             * If an dynamic unpacked array has more elements than this, then give up on building up the union type
                             */
                        Severity: Major
                        Found in src/Phan/AST/UnionTypeVisitor.php - About 1 day to fix

                          Function visitSwitchList has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function visitSwitchList(Node $node): Context
                              {
                                  // Make a copy of the internal context so that we don't
                                  // leak any changes within the closed context to the
                                  // outer scope
                          Severity: Minor
                          Found in src/Phan/BlockAnalysisVisitor.php - About 1 day 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

                          Method usage has 338 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function usage(string $msg = '', ?int $exit_code = EXIT_SUCCESS, int $usage_type = UsageException::PRINT_NORMAL, bool $forbid_color = true): void
                              {
                                  global $argv;
                          
                                  if ($msg !== '') {
                          Severity: Major
                          Found in src/Phan/CLI.php - About 1 day to fix

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

                                protected function getAvailableConstantPHPDocSummaries(): array
                                {
                                    return $this->memoize(__METHOD__, /** @return array<string,string> */ function (): array {
                                        $code_base = $this->code_base;
                                        $map = [];
                            Severity: Major
                            Found in internal/lib/IncompatibleStubsSignatureDetector.php and 1 other location - About 1 day to fix
                            internal/lib/IncompatibleRealStubsSignatureDetector.php on lines 383..428

                            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 357.

                            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

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

                                protected function getAvailableConstantPHPDocSummaries(): array
                                {
                                    return $this->memoize(__METHOD__, /** @return array<string,string> */ function (): array {
                                        $code_base = $this->code_base;
                                        $map = [];
                            Severity: Major
                            Found in internal/lib/IncompatibleRealStubsSignatureDetector.php and 1 other location - About 1 day to fix
                            internal/lib/IncompatibleStubsSignatureDetector.php on lines 364..409

                            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 357.

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language