Showing 3,272 of 4,939 total issues

File Bootstrap.php has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/**
Severity: Minor
Found in src/Phan/Bootstrap.php - About 3 hrs to fix

    Method visitClosure has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function visitClosure(Node $node): Context
        {
            $code_base = $this->code_base;
            $context = $this->context->withoutLoops();
            $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext(
    Severity: Major
    Found in src/Phan/Analysis/PreOrderAnalysisVisitor.php - About 3 hrs to fix

      Method getClassConst has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getClassConst(): ClassConstant
          {
              $node = $this->node;
              if (!($node instanceof Node)) {
                  throw new AssertionError('$this->node must be a node');
      Severity: Major
      Found in src/Phan/AST/ContextNode.php - About 3 hrs to fix

        Function addMethod has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            public function addMethod(
                CodeBase $code_base,
                Method $method,
                Option $type_option
            ): void {
        Severity: Minor
        Found in src/Phan/Language/Element/Clazz.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

        Function analyzeNode has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private function analyzeNode(Node $stmts): array
            {
                $kind = $stmts->kind;
                switch ($kind) {
                    // Nodes that create new scopes

        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 generateClosure has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function generateClosure(array $callable_params, array $class_params): Closure
            {
                $key = \json_encode([$callable_params, $class_params]);
                static $cache = [];
                $closure = $cache[$key] ?? null;
        Severity: Minor
        Found in src/Phan/Plugin/Internal/CallableParamPlugin.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

        Function isSimpleExpression has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function isSimpleExpression($arg): bool
            {
                if (\is_scalar($arg)) {
                    return true;
                }
        Severity: Minor
        Found in src/Phan/Plugin/Internal/StringFunctionPlugin.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

        Function visitStaticCall has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            public function visitStaticCall(Node $node): Context
            {
                // Get the name of the method being called
                $method_name = $node->children['method'];
        
        
        Severity: Minor
        Found in src/Phan/Analysis/PostOrderAnalysisVisitor.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

        Function createPassByReferenceArgumentInCall has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private function createPassByReferenceArgumentInCall(FunctionInterface $method, Node $argument, Parameter $parameter, ?Parameter $real_parameter): void
            {
                if ($argument->kind === ast\AST_VAR) {
                    // We don't do anything with the new variable; just create it
                    // if it doesn't exist
        Severity: Minor
        Found in src/Phan/Analysis/PostOrderAnalysisVisitor.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

        Function updateParameterTypeByArgument has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private function updateParameterTypeByArgument(
                FunctionInterface $method,
                Parameter $parameter,
                $argument,
                array $argument_types,
        Severity: Minor
        Found in src/Phan/Analysis/PostOrderAnalysisVisitor.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

        Function analyzeBinaryConditionSide has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private function analyzeBinaryConditionSide(Node $var_node, $expr_node, BinaryCondition $condition): ?Context
            {
                '@phan-var ConditionVisitorUtil|ConditionVisitorInterface $this';
                $kind = $var_node->kind;
                if ($kind === ast\AST_VAR || $kind === ast\AST_DIM) {
        Severity: Minor
        Found in src/Phan/Analysis/ConditionVisitorUtil.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

        Function phpParserTypeToAstNode has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function phpParserTypeToAstNode($type, int $line): ?ast\Node
            {
                if (\is_null($type)) {
                    return null;
                }
        Severity: Minor
        Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.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

        Function astStmtClass has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function astStmtClass(
                int $flags,
                ?string $name,
                ?\ast\Node $extends,
                ?\Microsoft\PhpParser\node\classinterfaceclause $implements,
        Severity: Minor
        Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.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

        Function checkMovedArg has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            private function checkMovedArg(FunctionInterface $function, array $args, Node $node, array $arg_names, array $places_set = []): void
            {
                $real_parameters = $function->getRealParameterList();
                $parameters = $function->getParameterList();
                /** @var associative-array<string,?int> maps lowercase param names to their unique index, or null */
        Severity: Minor
        Found in .phan/plugins/SuspiciousParamOrderPlugin.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

        Function visitMatchArmList has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            public function visitMatchArmList(Node $node): void
            {
                $children = $node->children;
                if (!$children) {
                    // This plugin will never emit errors if there are 0 elements.
        Severity: Minor
        Found in .phan/plugins/DuplicateArrayKeyPlugin.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 accept has 88 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function accept(CodeBase $code_base, Closure $file_path_lister, Responder $responder, bool $fork): ?Request
            {
                FileCache::clear();
        
                $request = $responder->getRequestData();
        Severity: Major
        Found in src/Phan/Daemon/Request.php - About 3 hrs to fix

          Method visitMethodCall has 88 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function visitMethodCall(Node $node): UnionType
              {
                  $method_name = $node->children['method'] ?? '';
          
                  // Give up on any complicated nonsense where the
          Severity: Major
          Found in src/Phan/AST/UnionTypeVisitor.php - About 3 hrs to fix

            MixedType has 29 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class MixedType extends NativeType
            {
                /** @phan-override */
                public const NAME = 'mixed';
            
            
            Severity: Minor
            Found in src/Phan/Language/Type/MixedType.php - About 3 hrs to fix

              VoidType has 29 functions (exceeds 20 allowed). Consider refactoring.
              Open

              final class VoidType extends NativeType implements LiteralTypeInterface
              {
                  /** @phan-override */
                  public const NAME = 'void';
              
              
              Severity: Minor
              Found in src/Phan/Language/Type/VoidType.php - About 3 hrs to fix

                LiteralStringType has 29 functions (exceeds 20 allowed). Consider refactoring.
                Open

                final class LiteralStringType extends StringType implements LiteralTypeInterface
                {
                
                    public const MINIMUM_MAX_STRING_LENGTH = 50;
                
                
                Severity: Minor
                Found in src/Phan/Language/Type/LiteralStringType.php - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language