Showing 3,272 of 4,939 total issues

Function methodFQSENListFromObjectAndMethodName has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function methodFQSENListFromObjectAndMethodName($class_or_expr, string $method_name): array
    {
        $code_base = $this->code_base;
        $context = $this->context;

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

Method visitIf has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function visitIf(Node $node): Context
    {
        $context = $this->context->withLineNumberStart(
            $node->lineno
        );
Severity: Major
Found in src/Phan/BlockAnalysisVisitor.php - About 3 hrs to fix

    Method visitBinaryAdd has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function visitBinaryAdd(Node $node): Context
        {
            return $this->updateTargetWithType($node, function (UnionType $left) use ($node): UnionType {
                $code_base = $this->code_base;
                $context = $this->context;
    Severity: Major
    Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 3 hrs to fix

      Method visitStaticCall has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function visitStaticCall(Node $node): Context
          {
              // Get the name of the method being called
              $method_name = $node->children['method'];
      
      
      Severity: Major
      Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 3 hrs to fix

        Method visitArray has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function visitArray(Node $node): UnionType
            {
                $children = $node->children;
                if (\count($children) > 0) {
                    $key_set = $this->getEquivalentArraySet($node);
        Severity: Major
        Found in src/Phan/AST/UnionTypeVisitor.php - About 3 hrs to fix

          Method loadMethodPlugins has 81 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function loadMethodPlugins(CodeBase $code_base): void
              {
                  $plugin_set = ConfigPluginSet::instance();
                  $return_type_overrides = $plugin_set->getReturnTypeOverrides($code_base);
                  $return_type_override_fqsen_strings = [];
          Severity: Major
          Found in src/Phan/Analysis.php - About 3 hrs to fix

            Method analyzeReturnValue has 81 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function analyzeReturnValue($expr_node, int $lineno, array &$sleep_properties): void
                {
                    $context = clone($this->context)->withLineNumberStart($lineno);
                    if (!($expr_node instanceof Node)) {
                        $this->emitPluginIssue(
            Severity: Major
            Found in .phan/plugins/SleepCheckerPlugin.php - About 3 hrs to fix

              Method checkUselessScalarComparison has 80 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function checkUselessScalarComparison(
                      Node $node,
                      UnionType $left,
                      UnionType $right,
                      $left_node,
              Severity: Major
              Found in src/Phan/Plugin/Internal/RedundantConditionVisitor.php - About 3 hrs to fix

                Method analyzeParameter has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function analyzeParameter(CodeBase $code_base, Context $context, FunctionInterface $method, UnionType $argument_type, int $lineno, int $i, $argument_node, ?Node $node): void
                    {
                        // Expand it to include all parent types up the chain
                        try {
                            $argument_type_expanded_resolved =
                Severity: Major
                Found in src/Phan/Analysis/ArgumentType.php - About 3 hrs to fix

                  File FlagVisitorImplementation.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

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

                    File Element.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

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

                      AssignOperatorAnalysisVisitor has 27 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class AssignOperatorAnalysisVisitor extends FlagVisitorImplementation
                      {
                      
                          /**
                           * @var CodeBase The code base within which we're operating
                      Severity: Minor
                      Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 3 hrs to fix

                        ASTSimplifier has 27 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        class ASTSimplifier
                        {
                            public function __construct()
                            {
                            }
                        Severity: Minor
                        Found in src/Phan/AST/ASTSimplifier.php - About 3 hrs to fix

                          Method addParamToScopeOfFunctionOrMethod has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function addParamToScopeOfFunctionOrMethod(
                                  Context $context,
                                  CodeBase $code_base,
                                  FunctionInterface $function,
                                  Comment $comment,
                          Severity: Major
                          Found in src/Phan/Language/Element/FunctionTrait.php - About 3 hrs to fix

                            Method analyzeShapedArrayAssignment has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function analyzeShapedArrayAssignment(Node $node): void
                                {
                                    // Figure out the type of elements in the list
                                    $fallback_element_type = null;
                                    /** @suppress PhanAccessMethodInternal */
                            Severity: Major
                            Found in src/Phan/Analysis/AssignmentVisitor.php - About 3 hrs to fix

                              Method analyzeElementReferenceCounts has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private static function analyzeElementReferenceCounts(
                                      CodeBase $code_base,
                                      AddressableElement $element,
                                      string $issue_type
                                  ): void {
                              Severity: Major
                              Found in src/Phan/Analysis/ReferenceCountsAnalyzer.php - About 3 hrs to fix

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

                                  Method addMethod has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function addMethod(
                                          CodeBase $code_base,
                                          Method $method,
                                          Option $type_option
                                      ): void {
                                  Severity: Major
                                  Found in src/Phan/Language/Element/Clazz.php - About 3 hrs to fix

                                    Method visitDim has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function visitDim(Node $node): Context
                                        {
                                            $expr_node = $node->children['expr'];
                                            if (!($expr_node instanceof Node)) {
                                                $this->emitIssue(
                                    Severity: Major
                                    Found in src/Phan/Analysis/AssignmentVisitor.php - About 3 hrs to fix

                                      Function parameterFromCommentLine has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          private function parameterFromCommentLine(
                                              string $line,
                                              bool $is_var,
                                              int $i
                                          ): Parameter {
                                      Severity: Minor
                                      Found in src/Phan/Language/Element/Comment/Builder.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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language