Showing 3,272 of 4,939 total issues
Function removeShebang
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function removeShebang(string $file_contents): string
{
if (\substr($file_contents, 0, 2) !== "#!") {
return $file_contents;
}
- Read upRead up
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 analyzeSingleThrowType
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static function analyzeSingleThrowType(
CodeBase $code_base,
FunctionInterface $method,
Type $type
): bool {
- Read upRead up
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 visitBinaryOp
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function visitBinaryOp(Node $node): Context
{
$flags = $node->flags;
if ($this->isInNoOpPosition($node)) {
if (\in_array($flags, [flags\BINARY_BOOL_AND, flags\BINARY_BOOL_OR, flags\BINARY_COALESCE], true)) {
- Read upRead up
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 isAssignmentOrNestedAssignmentOrModification
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function isAssignmentOrNestedAssignmentOrModification(Node $node): ?bool
{
$parent_node_list = $this->parent_node_list;
$parent_node = \end($parent_node_list);
if (!$parent_node instanceof Node) {
- Read upRead up
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 couldRealTypesHaveKey
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static function couldRealTypesHaveKey(array $real_type_set, $dim_value): bool
{
foreach ($real_type_set as $type) {
if ($type instanceof ArrayShapeType) {
if (\array_key_exists($dim_value, $type->getFieldTypes())) {
- Read upRead up
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 getVariableName
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getVariableName(): string
{
if (!($this->node instanceof Node)) {
return (string)$this->node;
}
- Read upRead up
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 processVariableInString
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function processVariableInString(File $phpcs_file, $stack_ptr)
{
if ($this->isExcluded($phpcs_file)) {
return;
}
- Read upRead up
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 parseClassName
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function parseClassName(string $folder_in_reference_directory): string
{
foreach ($this->getPossibleFilesInReferenceDirectory($folder_in_reference_directory) as $file_in_reference_directory) {
//echo "Looking for $file_in_reference_directory\n";
if (file_exists($file_in_reference_directory)) {
- Read upRead up
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 compareNamedParameters
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function compareNamedParameters(): void
{
if (PHP_MAJOR_VERSION < 8) {
fwrite(STDERR, "compare-named-parameters MUST BE RUN IN PHP 8.0+, BUT WAS RUN IN " . PHP_VERSION . "\n");
fwrite(STDERR, "exiting without generating stubs\n");
- Read upRead up
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 extractStringsFromStringOrArray
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static function extractStringsFromStringOrArray(
CodeBase $code_base,
Context $context,
$pattern
): array {
- Read upRead up
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 beforeAnalyzePhase
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function beforeAnalyzePhase(CodeBase $code_base): void
{
foreach (self::KNOWN_ALIASES as $alias => $original_name) {
try {
$fqsen = FullyQualifiedFunctionName::fromFullyQualifiedString($alias);
- Read upRead up
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 generateCompletions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function generateCompletions(string $text, int $start, int $end): array
{
$this->setReadlineConfig('completion_append_character', "\x00");
try {
// TODO: PHP's API only allows us to fetch the most recent line.
- Read upRead up
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 checkAllArgsUsed
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function checkAllArgsUsed(array $opts, array &$argv): void
{
$pruneargv = [];
foreach ($opts as $opt => $value) {
foreach ($argv as $key => $chunk) {
Method magicPropertyFromCommentLine
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function magicPropertyFromCommentLine(
string $line,
int $i
): ?Property {
// Note that the type of a property can be left out (@property $myVar) - This is equivalent to @property mixed $myVar
Method canCastToNonNullableType
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function canCastToNonNullableType(Type $type): bool
{
if ($type instanceof ArrayType) {
if ($type instanceof GenericArrayType) {
return $this->canCastToGenericArrayKeys($type) &&
Method canCastToNonNullableTypeWithoutConfig
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function canCastToNonNullableTypeWithoutConfig(Type $type): bool
{
if ($type instanceof ArrayType) {
if ($type instanceof GenericArrayType) {
// TODO: WithoutConfig here as well?
Method applyNumericOperationToList
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function applyNumericOperationToList(array $type_set, Closure $operation): array
{
$added_fallbacks = false;
$result = [];
foreach ($type_set as $type) {
Method genericArrayElementTypes
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function genericArrayElementTypes(bool $add_real_types = false): UnionType
{
// This is frequently called, and has been optimized
$result = [];
$type_set = $this->type_set;
Method warnAboutCouldBeConstant
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function warnAboutCouldBeConstant(VariableGraph $graph, string $variable_name, int $definition_id, $value_node): void
{
$issue_type = Issue::VariableDefinitionCouldBeConstant;
if ($value_node instanceof Node) {
if ($value_node->kind === ast\AST_ARRAY) {
Method shouldWarnAboutImpossibleInArray
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function shouldWarnAboutImpossibleInArray(CodeBase $code_base, Context $context, array $args, ?UnionType $needle_type = null, ?UnionType $haystack_type = null): bool
{
$haystack_type = $haystack_type ?? UnionTypeVisitor::unionTypeFromNode($code_base, $context, $args[1]);
if (!$haystack_type->hasRealTypeSet()) {
return false;