Showing 4,939 of 4,939 total issues

Function getRequestData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRequestData(): ?array
    {
        if (!$this->did_read_request_data) {
            $response_connection = $this->connection;
            if (!$response_connection) {
Severity: Minor
Found in src/Phan/Daemon/Transport/StreamResponder.php - About 35 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 locateClassCompletion has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function locateClassCompletion(
        CompletionRequest $request,
        CodeBase $code_base,
        Context $context,
        Node $node,
Severity: Minor
Found in src/Phan/LanguageServer/CompletionResolver.php - About 35 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 supportsColor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function supportsColor($output): bool
    {
        if (self::isDaemonOrLanguageServer()) {
            return false;
        }
Severity: Minor
Found in src/Phan/CLI.php - About 35 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 didChangeWatchedFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function didChangeWatchedFiles(array $changes): void
    {
        // invalidate Phan's cache for these files if changed, added, or modified outside of the IDE
        foreach ($changes as $change) {
            $this->file_mapping->removeOverrideURI($change->uri);
Severity: Minor
Found in src/Phan/LanguageServer/Server/Workspace.php - About 35 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 kindForElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function kindForElement(TypedElementInterface $element): ?int
    {
        if ($element instanceof ClassConstant) {
            return CompletionItemKind::VARIABLE;
        } elseif ($element instanceof Clazz) {
Severity: Minor
Found in src/Phan/LanguageServer/CompletionRequest.php - About 35 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 checkCanDaemonize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkCanDaemonize(string $protocol, string $opt): void
    {
        $opt = strlen($opt) >= 2 ? "--$opt" : "-$opt";
        if (!in_array($protocol, \stream_get_transports(), true)) {
            throw new UsageException("The $protocol:///path/to/file schema is not supported on this system, cannot create a daemon with $opt", 1);
Severity: Minor
Found in src/Phan/CLI.php - About 35 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 locateClassDefinitionForUnionType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function locateClassDefinitionForUnionType(
        GoToDefinitionRequest $request,
        CodeBase $code_base,
        UnionType $union_type
    ): bool {
Severity: Minor
Found in src/Phan/LanguageServer/DefinitionResolver.php - About 35 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 preloadBeforeForkingAnalysisWorkers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function preloadBeforeForkingAnalysisWorkers(CodeBase $code_base): void
    {
        if (Config::getValue('language_server_use_pcntl_fallback')) {
            return;
        }
Severity: Minor
Found in src/Phan/Phan.php - About 35 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 createGoToDefinitionClosure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function createGoToDefinitionClosure(GoToDefinitionRequest $request, CodeBase $code_base): Closure
    {
        /**
         * @param list<Node> $parent_node_list
         */
Severity: Minor
Found in src/Phan/LanguageServer/DefinitionResolver.php - About 35 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 isTemplateTypeUsed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function isTemplateTypeUsed(TemplateType $type): bool
    {
        if ($this->getUnionType()->usesTemplateType($type)) {
            // used in `@return`
            return true;
Severity: Minor
Found in src/Phan/Language/Element/FunctionTrait.php - About 35 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 computeNeedsRecursiveAnalysis has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function computeNeedsRecursiveAnalysis(): bool
    {
        if (!$this->getNode()) {
            // E.g. this can be the case for magic methods, internal methods, stubs, etc.
            return false;
Severity: Minor
Found in src/Phan/Language/Element/FunctionTrait.php - About 35 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 checkCanAccessProtectedElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function checkCanAccessProtectedElement(CodeBase $code_base, FullyQualifiedClassName $defining_fqsen, FullyQualifiedClassName $accessing_class_fqsen): bool
    {
        $accessing_class_type = $accessing_class_fqsen->asType();
        $type_of_class_of_property = $defining_fqsen->asType();

Severity: Minor
Found in src/Phan/Language/Element/ClassElement.php - About 35 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 isSubtypeOf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function isSubtypeOf(Type $type): bool
    {
        // TODO more specific
        if (!$this->canCastToType($type)) {
            return false;
Severity: Minor
Found in src/Phan/Language/Type/GenericArrayType.php - About 35 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 keyTypeFromUnionTypeKeys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function keyTypeFromUnionTypeKeys(UnionType $union_type): int
    {
        $key_types = self::KEY_EMPTY;
        foreach ($union_type->getTypeSet() as $type) {
            if ($type instanceof GenericArrayType) {
Severity: Minor
Found in src/Phan/Language/Type/GenericArrayType.php - About 35 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 getNamespaceMapFor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getNamespaceMapFor(
        int $flags,
        string $name
    ): FullyQualifiedGlobalStructuralElement {

Severity: Minor
Found in src/Phan/Language/Context.php - About 35 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 toFunctionSignatureArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function toFunctionSignatureArray(): array
    {
        // no need for returns ref yet
        $return_type = $this->return_type;
        $stub = [$return_type->__toString()];
Severity: Minor
Found in src/Phan/Language/Type/FunctionLikeDeclarationType.php - About 35 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 withAssociativeArraysForSet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function withAssociativeArraysForSet(array $type_set, bool $can_reduce_size): array
    {
        foreach ($type_set as $i => $type) {
            if (!$type instanceof ArrayType) {
                continue;
Severity: Minor
Found in src/Phan/Language/UnionType.php - About 35 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 nonFalseClone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function nonFalseClone(): UnionType
    {
        $builder = new UnionTypeBuilder();
        $did_change = false;
        foreach ($this->type_set as $type) {
Severity: Minor
Found in src/Phan/Language/UnionType.php - About 35 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 hasLiterals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function hasLiterals(): bool
    {
        foreach ($this->type_set as $type) {
            if ($type instanceof LiteralTypeInterface) {
                $value = $type->getValue();
Severity: Minor
Found in src/Phan/Language/UnionType.php - About 35 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 instance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function instance(bool $is_nullable)
    {
        if ($is_nullable) {
            static $nullable_instance = null;

Severity: Minor
Found in src/Phan/Language/Type/ClosureType.php - About 35 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

Severity
Category
Status
Source
Language