Showing 3,272 of 4,939 total issues

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

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

    Method visitForeach has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Method analyzeGenericArrayAssignment has 86 lines of code (exceeds 25 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: Major
      Found in src/Phan/Analysis/AssignmentVisitor.php - About 3 hrs to fix

        Method main has 86 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function main(): void
            {
                error_reporting(E_ALL);
                ini_set('memory_limit', '2G');
                global $argv;
        Severity: Major
        Found in internal/lib/IncompatibleXMLSignatureDetector.php - About 3 hrs to fix

          Function locateNamespaceUseDefinition has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function locateNamespaceUseDefinition(GoToDefinitionRequest $request, CodeBase $code_base, Node $node): void
              {
                  // TODO: Support GroupUse (See ScopeVisitor->visitGroupUse)
                  $targets = ScopeVisitor::aliasTargetMapFromUseNode($node);
                  if (count($targets) !== 1) {
          Severity: Minor
          Found in src/Phan/LanguageServer/DefinitionResolver.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 canCastToUnionType has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              public function canCastToUnionType(
                  UnionType $target
              ): bool {
                  // Fast-track most common cases first
                  $type_set = $this->type_set;
          Severity: Minor
          Found in src/Phan/Language/UnionType.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 visitFor has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              public function visitFor(Node $node): Context
              {
                  $context = $this->context->withLineNumberStart(
                      $node->lineno
                  );
          Severity: Minor
          Found in src/Phan/BlockAnalysisVisitor.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 addEntriesForClass has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function addEntriesForClass(
                  CtagsEntrySet $entries,
                  CodeBase $code_base,
                  FullyQualifiedClassName $class_fqsen,
                  Clazz $class
          Severity: Minor
          Found in src/Phan/Plugin/Internal/CtagsPlugin.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 addParametersAndUseVariablesToGraph has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function addParametersAndUseVariablesToGraph(
                  Node $node,
                  VariableGraph $graph,
                  VariableTrackingScope $scope
              ): array {
          Severity: Minor
          Found in src/Phan/Plugin/Internal/VariableTrackerPlugin.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 ensurePluginsExist has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private function ensurePluginsExist(): void
              {
                  if (!is_null($this->plugin_set)) {
                      return;
                  }
          Severity: Minor
          Found in src/Phan/Plugin/ConfigPluginSet.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 analyzeParameterStrict has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function analyzeParameterStrict(CodeBase $code_base, Context $context, FunctionInterface $method, $argument_node, UnionType $argument_type, Variable $alternate_parameter, UnionType $parameter_type, int $lineno, int $i): void
              {
                  if ($alternate_parameter instanceof Parameter && $alternate_parameter->isPassByReference() && $alternate_parameter->getReferenceType() === Parameter::REFERENCE_WRITE_ONLY) {
                      return;
                  }
          Severity: Minor
          Found in src/Phan/Analysis/ArgumentType.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 checkComplexIsset has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              public function checkComplexIsset(Node $var_node): Context
              {
                  $context = $this->context;
                  if ($var_node->kind === ast\AST_DIM) {
                      $expr_node = $var_node;
          Severity: Minor
          Found in src/Phan/Analysis/NegatedConditionVisitor.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 warnNoopNew has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private function warnNoopNew(
                  Node $node,
                  array $class_list
              ): void {
                  $has_constructor_or_destructor = \count($class_list) === 0;
          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 analyzePluginSuppressionsForFile has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private function analyzePluginSuppressionsForFile(CodeBase $code_base, SuppressionCapability $plugin, string $relative_file_path): void
              {
                  $absolute_file_path = Config::projectPath($relative_file_path);
                  $plugin_class = \get_class($plugin);
                  $name_pos = \strrpos($plugin_class, '\\');
          Severity: Minor
          Found in .phan/plugins/UnusedSuppressionPlugin.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 visitSwitchList has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              public function visitSwitchList(Node $node): void
              {
                  $children = $node->children;
                  if (count($children) <= 1) {
                      // This plugin will never emit errors if there are 0 or 1 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

          Function warnAboutTransientSleepProperties has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              private function warnAboutTransientSleepProperties(array $sleep_properties): void
              {
                  if (count($sleep_properties) === 0) {
                      // Give up, failed to extract property names
                      return;
          Severity: Minor
          Found in .phan/plugins/SleepCheckerPlugin.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 fromFullyQualifiedStringInner has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected static function fromFullyQualifiedStringInner(
                  string $fully_qualified_string
              ): Type {
                  if ($fully_qualified_string === '') {
                      throw new InvalidArgumentException("Type cannot be empty");
          Severity: Major
          Found in src/Phan/Language/Type.php - About 3 hrs to fix

            Method methodFQSENListFromParts has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function methodFQSENListFromParts($class_or_expr, $method_name): array
                {
                    $code_base = $this->code_base;
                    $context = $this->context;
            
            
            Severity: Major
            Found in src/Phan/AST/UnionTypeVisitor.php - About 3 hrs to fix

              Method visitAssign has 85 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function visitAssign(Node $node): void
                  {
                      $var = $node->children['var'];
                      if (!$var instanceof Node) {
                          return;
              Severity: Major
              Found in .phan/plugins/RedundantAssignmentPlugin.php - About 3 hrs to fix

                File phan_repl_helpers.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                declare(strict_types=1);
                
                use Phan\CLI;
                Severity: Minor
                Found in tool/phan_repl_helpers.php - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language