Showing 3,272 of 4,939 total issues

Function visitIf has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitIf(Node $node): VariableTrackingScope
    {
        $outer_scope = $this->scope;

        $inner_scope_list = [];
Severity: Minor
Found in src/Phan/Plugin/Internal/VariableTracker/VariableTrackerVisitor.php - About 1 hr 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 findStringsBeginningWith has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function findStringsBeginningWith(string $name): array
    {
        $name = \strtolower($name);
        $name_len = strlen($name);
        $start = 0;
Severity: Minor
Found in src/Phan/Library/StringSuggester.php - About 1 hr 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 normalizeListTypesInDimAssignment has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private static function normalizeListTypesInDimAssignment(UnionType $assign_type, UnionType $right_type): UnionType
    {
        // Offsets of $can_cast:
        // 0. lazily computed: True if list types should be kept as-is.
        // 1. lazily computed: Should this cast from a regular array to an associative array?
Severity: Minor
Found in src/Phan/Analysis/AssignmentVisitor.php - About 1 hr 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 analyzeSetUnionTypePassByRef has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private static function analyzeSetUnionTypePassByRef(
        CodeBase $code_base,
        Context $context,
        PassByReferenceVariable $reference_element,
        UnionType $new_type,
Severity: Minor
Found in src/Phan/Analysis/AssignmentVisitor.php - About 1 hr 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 checkAssignmentToFunctionResult has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkAssignmentToFunctionResult(Node $node, iterable $function_list_generator): void
    {
        try {
            foreach ($function_list_generator as $function) {
                if ($function->returnsRef()) {
Severity: Minor
Found in src/Phan/Analysis/AssignmentVisitor.php - About 1 hr 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 analyzeDuplicateClass has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function analyzeDuplicateClass(
        CodeBase $code_base,
        Clazz $clazz
    ): void {
        // Determine if it's a duplicate by looking to see if
Severity: Minor
Found in src/Phan/Analysis/DuplicateClassAnalyzer.php - About 1 hr 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 getStaticMethodOrEmitIssue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function getStaticMethodOrEmitIssue(Node $node, string $method_name): ?Method
    {
        try {
            // Get a reference to the method being called
            $result = (new ContextNode(
Severity: Minor
Found in src/Phan/Analysis/PostOrderAnalysisVisitor.php - About 1 hr 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 astStmtGroupUse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private static function astStmtGroupUse(?int $type, ?string $prefix, array $uses, int $line): ast\Node
    {
        $flags = static::phpParserNamespaceUseKindToASTUseFlags($type);
        $uses = new ast\Node(ast\AST_USE, 0, $uses, $line);
        if ($flags === flags\USE_NORMAL) {
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php - About 1 hr 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 phpParserListToAstList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private static function phpParserListToAstList(PhpParser\Node\Expression\ListIntrinsicExpression $n, int $start_line): ast\Node
    {
        $ast_items = [];
        $prev_was_element = false;
        foreach ($n->listElements->children ?? [] as $item) {
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php - About 1 hr 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 getPackedArrayFieldTypes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function getPackedArrayFieldTypes($expr): ?array
    {
        if (!$expr instanceof Node) {
            // TODO: Warn if non-array
            return null;
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.php - About 1 hr 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 handleTraitPrecedence has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function handleTraitPrecedence(array $adaptations_map, Node $adaptation_node): void
    {
        // TODO: Should also verify that the original method exists, in a future PR?
        $trait_method_node = $adaptation_node->children['method'];
        if (!$trait_method_node instanceof Node) {
Severity: Minor
Found in src/Phan/AST/ContextNode.php - About 1 hr 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 updateFunctionSignaturesParamNames has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function updateFunctionSignaturesParamNames(): void
    {
        $phan_signatures = static::readSignatureMap();
        $new_signatures = [];
        foreach ($phan_signatures as $method_name => $arguments) {
Severity: Minor
Found in internal/lib/IncompatibleRealStubsSignatureDetector.php - About 1 hr 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 __construct has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct(string $binary, string $file_contents, Context $context)
    {
        $this->context = clone($context);
        $new_file_contents = Parser::removeShebang($file_contents);
        // TODO: Use symfony process
Severity: Minor
Found in .phan/plugins/InvokePHPNativeSyntaxCheckPlugin.php - About 1 hr 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 arrayTypeFromFlags has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private static function arrayTypeFromFlags(array $flag_set): UnionType
    {
        // 1. Convert key types from opcache to Phan's representation
        if (isset($flag_set['MAY_BE_ARRAY_KEY_ANY'])) {
            $key_type = GenericArrayType::KEY_MIXED;
Severity: Minor
Found in internal/extract_arg_info.php - About 1 hr 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 visitAssign has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitAssign(Node $node): void
    {
        $expr = $node->children['expr'];
        if (!$expr instanceof Node) {
            // Guaranteed not to contain duplicate expressions in valid php assignments.
Severity: Minor
Found in .phan/plugins/DuplicateExpressionPlugin.php - About 1 hr 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 resolveTemplateType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function resolveTemplateType(
        CodeBase $code_base,
        UnionType $object_union_type
    ): Method {
        $defining_fqsen = $this->getDefiningClassFQSEN();
Severity: Minor
Found in src/Phan/Language/Element/Method.php - About 1 hr to fix

    Method canCastToNonNullableType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function canCastToNonNullableType(Type $type): bool
        {
            if ($type instanceof ScalarType) {
                switch ($type::NAME) {
                    case 'int':
    Severity: Minor
    Found in src/Phan/Language/Type/LiteralIntType.php - About 1 hr to fix

      Method iterableKeyUnionType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function iterableKeyUnionType(CodeBase $code_base): UnionType
          {
              // This is frequently called, and has been optimized
              $new_type_builder = new UnionTypeBuilder();
              foreach ($this->type_set as $type) {
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 1 hr to fix

        Method iterableValueUnionType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function iterableValueUnionType(CodeBase $code_base): UnionType
            {
                // This is frequently called, and has been optimized
                // TODO: Support real types if the type set is exclusively real iterable types
                $builder = new UnionTypeBuilder();
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 1 hr to fix

          Method asNormalizedTypeSetInner has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function asNormalizedTypeSetInner(array $type_set): array
              {
                  if (\count($type_set) <= 1) {
                      return $type_set;
                  }
          Severity: Minor
          Found in src/Phan/Language/UnionType.php - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language