Showing 3,272 of 4,939 total issues

Function afterAnalyzeFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function afterAnalyzeFile(CodeBase $code_base, Context $context, string $file_contents, Node $node): void
    {
        $path = $context->getFile();
        if (Paths::isAbsolutePath($path) ||  \strpos($path, '../') !== false) {
            CLI::printToStderr("phantasm: Skipping '$path': Only modifying files within the project directory\n");
Severity: Minor
Found in src/Phan/Plugin/Internal/PhantasmPlugin.php - About 45 mins 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 emit has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        string $issue_type,
        string $issue_message_fmt,
        array $issue_message_args = [],
        int $severity = Issue::SEVERITY_NORMAL,
        int $remediation_difficulty = Issue::REMEDIATION_B,
Severity: Minor
Found in src/Phan/PluginV3/PluginAwareBaseAnalysisVisitor.php - About 45 mins to fix

    Function visitVar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function visitVar(Node $node): VariableTrackingScope
        {
            $name = $node->children['name'];
            if (\is_string($name)) {
                self::$variable_graph->recordVariableUsage($name, $node, $this->scope);
    Severity: Minor
    Found in src/Phan/Plugin/Internal/VariableTracker/VariableTrackerVisitor.php - About 45 mins 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 shouldSuppressIssue has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            CodeBase $code_base,
            Context $context,
            string $issue_type,
            int $lineno,
            array $parameters,
    Severity: Minor
    Found in src/Phan/Plugin/ConfigPluginSet.php - About 45 mins to fix

      Method shouldSuppressIssue has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              CodeBase $code_base,
              Context $context,
              string $issue_type,
              int $lineno,
              array $parameters,
      Severity: Minor
      Found in src/Phan/PluginV3/SuppressionCapability.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                        if ($class->isTrait()) {
                                            $issue_type = Issue::AbstractStaticMethodCallInTrait;
                                        }
        Severity: Major
        Found in src/Phan/Analysis/ArgumentType.php - About 45 mins to fix

          Function analyzeShortCircuitingOr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function analyzeShortCircuitingOr($left, $right): Context
              {
                  // Aside: If left/right is not a node, left/right is a literal such as a number/string, and is either always truthy or always falsey.
                  // Inside of this conditional may be dead or redundant code.
                  if (!($left instanceof Node)) {
          Severity: Minor
          Found in src/Phan/Analysis/ConditionVisitor.php - About 45 mins 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 analyzeShortCircuitingAnd has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function analyzeShortCircuitingAnd($left, $right): Context
              {
                  // Analyze expressions such as if (!(is_string($x) || is_int($x)))
                  // which would be equivalent to if (!is_string($x)) { if (!is_int($x)) { ... }}
          
          
          Severity: Minor
          Found in src/Phan/Analysis/NegatedConditionVisitor.php - About 45 mins 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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  CodeBase $code_base,
                  Context $context,
                  Node $assignment_node,
                  UnionType $right_type,
                  int $dim_depth = 0,
          Severity: Minor
          Found in src/Phan/Analysis/AssignmentVisitor.php - About 45 mins to fix

            Method warnAboutInvalidUnionType has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    Node $node,
                    Closure $is_valid_type,
                    UnionType $left,
                    UnionType $right,
                    string $left_issue_type,
            Severity: Minor
            Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ($this->context->isInGlobalScope()) {
                                          return $this->updateTargetWithType($assign_op_node, $get_type);
                                      }
              Severity: Major
              Found in src/Phan/Analysis/AssignOperatorAnalysisVisitor.php - About 45 mins to fix

                Method maybeWarnProvidingUnusedParameter has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        CodeBase $code_base,
                        Context $context,
                        int $lineno,
                        FunctionInterface $method,
                        Parameter $parameter,
                Severity: Minor
                Found in src/Phan/Analysis/ArgumentType.php - About 45 mins to fix

                  Function checkIsDeprecatedOrInternal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static function checkIsDeprecatedOrInternal(CodeBase $code_base, Context $context, FunctionInterface $method): void
                      {
                          // Special common cases where we want slightly
                          // better multi-signature error messages
                          if ($method->isPHPInternal()) {
                  Severity: Minor
                  Found in src/Phan/Analysis/ArgumentType.php - About 45 mins 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 createNegationCallbackMap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static function createNegationCallbackMap(): array
                      {
                          /** @param list<Node|mixed> $unused_args */
                          $remove_null_cb = static function (CodeBase $unused_code_base, Context $unused_context, Variable $variable, array $unused_args): void {
                              $variable->setUnionType($variable->getUnionType()->nonNullableClone());
                  Severity: Minor
                  Found in src/Phan/Analysis/NegatedConditionVisitor.php - About 45 mins 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 withSetArrayShapeTypes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function withSetArrayShapeTypes(UnionType $union_type, $dim_node, Context $context, bool $non_nullable): UnionType
                      {
                          $dim_value = $dim_node instanceof Node ? (new ContextNode($this->code_base, $context, $dim_node))->getEquivalentPHPScalarValue() : $dim_node;
                          // TODO: detect and warn about null
                          if (!\is_scalar($dim_value)) {
                  Severity: Minor
                  Found in src/Phan/Analysis/ConditionVisitor.php - About 45 mins 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 withNonFalseyArrayShapeTypes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function withNonFalseyArrayShapeTypes(Variable $variable, $dim_node, Context $context, bool $non_nullable): Context
                      {
                          $dim_value = $dim_node instanceof Node ? (new ContextNode($this->code_base, $this->context, $dim_node))->getEquivalentPHPScalarValue() : $dim_node;
                          // TODO: detect and warn about null
                          if (!\is_scalar($dim_value)) {
                  Severity: Minor
                  Found in src/Phan/Analysis/NegatedConditionVisitor.php - About 45 mins 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 updateVariableWithNewType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      final protected function updateVariableWithNewType(
                          Node $var_node,
                          Context $context,
                          UnionType $new_union_type,
                          bool $suppress_issues,
                  Severity: Minor
                  Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 45 mins 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 tryToAssignPHPDocTypeToParameter has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          CodeBase $code_base,
                          FunctionInterface $method,
                          int $i,
                          Parameter $parameter,
                          UnionType $real_param_type,
                  Severity: Minor
                  Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 45 mins to fix

                    Function analyzeOverrideSignature has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static function analyzeOverrideSignature(
                            CodeBase $code_base,
                            Method $method
                        ): void {
                            if (!Config::getValue('analyze_signature_compatibility')) {
                    Severity: Minor
                    Found in src/Phan/Analysis/ParameterTypesAnalyzer.php - About 45 mins 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 updateDimExpressionWithConditionalFilter has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            Node $node,
                            Context $context,
                            Closure $should_filter_cb,
                            Closure $filter_union_type_cb,
                            bool $suppress_issues,
                    Severity: Minor
                    Found in src/Phan/Analysis/ConditionVisitorUtil.php - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language