Showing 3,272 of 4,939 total issues
Function visitBinaryOp
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function visitBinaryOp(Node $node): Context
{
// get the types of left and right values
$left_node = $node->children['left'];
$left_type = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $left_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 visitReturn
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function visitReturn(Node $node): void
{
if (!$this->context->isInFunctionLikeScope()) {
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 computeEditsForParamTypeDeclaration
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function computeEditsForParamTypeDeclaration(FileCacheEntry $contents, FunctionLike $declaration, string $param_name, string $param_type): ?FileEditSet
{
if ($param_type === '') {
return null;
}
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
public function beforeAnalyzePhase(CodeBase $code_base): void
{
$ignore_overrides = (bool)getenv('PHPDOC_TO_REAL_TYPES_IGNORE_INHERITANCE');
foreach ($this->deferred_analysis_methods as $method) {
if ($method->isOverride() || $method->isOverriddenByAnother()) {
- 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 determineShorterType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function determineShorterType(Context $context, Node $type_node): ?string
{
if ($type_node->kind !== ast\AST_NAME) {
return null;
}
- 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 generateInstanceObjectCompletions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function generateInstanceObjectCompletions(array $tokens): array
{
$i = count($tokens) - 1;
$this->appendToLogFile("generateInstanceObjectCompletions tokens = " . StringUtil::jsonEncode($tokens) . "\n");
while (!is_array($tokens[$i]) || $tokens[$i][0] !== T_OBJECT_OPERATOR) {
- 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 analyzeStatementsOfSleep
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeStatementsOfSleep($node, array &$sleep_properties = []): void
{
if (!($node instanceof Node)) {
if (is_array($node)) {
foreach ($node as $child_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 extractIfElseifChain
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function extractIfElseifChain(Node $node): array
{
$children = $node->children;
if (count($children) <= 1) {
return $children;
- 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 checkForSuspiciousRegexPatterns
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function checkForSuspiciousRegexPatterns(string $pattern): Generator
{
$pattern = \trim($pattern);
$start_chr = $pattern[0] ?? '/';
- 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 visitConditional
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function visitConditional(Node $node): void
{
$cond_node = $node->children['cond'];
$true_node_hash = ASTHasher::hash($node->children['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
Consider simplifying this complex logical expression. Open
if ($this instanceof Func || ($this instanceof Method && ($this->isPrivate() || $this->isEffectivelyFinal() || $this->isMagicAndVoid() || $this->getClass($code_base)->isFinal()))) {
$this->setUnionType(VoidType::instance(false)->asPHPDocUnionType());
}
Consider simplifying this complex logical expression. Open
if (Config::getValue('unused_variable_detection') &&
!$expression_union_type->isEmpty() && !$expression_union_type->hasPossiblyObjectTypes() &&
InferPureSnippetVisitor::isSideEffectFreeSnippet($this->code_base, $inner_context, $stmts_node) &&
self::isLoopVariableWithoutSideEffects($node->children['key']) &&
self::isLoopVariableWithoutSideEffects($node->children['value'])
Consider simplifying this complex logical expression. Open
if ($o_real_parameter !== null && $real_parameter !== null && !$real_parameter->getUnionType()->isEmptyOrMixed() && $o_real_parameter->getUnionType()->isEmptyOrMixed()
&& (!$method->isFromPHPDoc() || $parameter->getUnionType()->isEmptyOrMixed())) {
$signatures_match = false;
$mismatch_details = "Cannot use $parameter with a real type to override parameter $o_parameter without a real type";
break;
Method progress
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $msg,
float $p,
$details = null,
?int $offset = null,
?int $count = null
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(string $message = null, Range $range = null, int $code = null, int $severity = null, string $source = null)
Method locateGlobalConstantCompletion
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
CompletionRequest $request,
CodeBase $code_base,
Context $context,
Node $node,
string $incomplete_constant_name
Method locateClassConstantCompletion
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
CompletionRequest $request,
CodeBase $code_base,
Context $context,
Node $node,
$constant_name
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
array $internal_class_name_list,
array $internal_interface_name_list,
array $internal_trait_name_list,
array $internal_constant_name_list,
array $internal_function_name_list
Method renderLongProgress
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function renderLongProgress(string $msg, float $p, float $memory, ?int $offset, ?int $count): string
Method locateClassCompletion
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
CompletionRequest $request,
CodeBase $code_base,
Context $context,
Node $node,
string $incomplete_class_name