Showing 3,272 of 4,939 total issues
Function getKnownClasses
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function getKnownClasses(): array
{
static $known_classes = null;
if (!is_array($known_classes)) {
$known_classes = MarkupDescription::loadClassDescriptionMap();
- 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 preAnalyzeIfElemCondition
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function preAnalyzeIfElemCondition(Node $if_elem_node, Context $fallthrough_context): array
{
$condition_node = $if_elem_node->children['cond'];
if ($condition_node instanceof Node) {
if ($condition_node->kind === ast\AST_BINARY_OP) {
- 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 suggestSimilarClassConstant
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function suggestSimilarClassConstant(CodeBase $code_base, Context $context, FullyQualifiedClassConstantName $class_constant_fqsen): ?Suggestion
{
if (Config::getValue('disable_suggestions')) {
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 handleScalarStmt
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function handleScalarStmt(Node $node, Context $context, $child_node): void
{
if (\is_string($child_node)) {
$consumed = false;
if (\strpos($child_node, '@phan-') !== false) {
- 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 visitTry
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function visitTry(Node $node): Context
{
$context = $this->context->withLineNumberStart(
$node->lineno
);
- 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 getNextTypeId
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function getNextTypeId(array $issue_list, int $invalid_type_id): int
{
for ($id = $invalid_type_id + 1; true; $id++) {
foreach ($issue_list as $error) {
if ($error->getTypeId() === $id) {
- 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 generateClosureForFunctionInterface
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function generateClosureForFunctionInterface(FunctionInterface $function): ?Closure
{
$callable_params = [];
$class_params = [];
foreach ($function->getParameterList() as $i => $param) {
- 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 isVoidFunction
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function isVoidFunction(FunctionInterface $function): bool
{
if ($function->getUnionType()->isNull()) {
return 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 getAbsolutePath
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getAbsolutePath(Node $node, string $relative_path): string
{
if (Paths::isAbsolutePath($relative_path)) {
return $relative_path;
}
- 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 computeClosestTargetPHPVersionId
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function computeClosestTargetPHPVersionId(string $version): int
{
if (\version_compare($version, '6.0') < 0) {
return 50600;
} elseif (\version_compare($version, '7.1') < 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 isCastableButNotSubtype
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function isCastableButNotSubtype(UnionType $actual_type, Type $inner_type): bool
{
if ($inner_type instanceof ObjectType) {
foreach ($actual_type->getTypeSet() as $type) {
if ($type->isPossiblyObject() && !$type->isObjectWithKnownFQSEN()) {
- 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 analyzeArrayAssignmentTarget
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeArrayAssignmentTarget(Node $node, $const_expr): VariableTrackingScope
{
foreach ($node->children as $elem_node) {
if (!($elem_node instanceof Node)) {
continue;
- 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 analyzePropAssignmentTarget
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function analyzePropAssignmentTarget(Node $node): VariableTrackingScope
{
// Treat $y in `$x->$y = $z;` as a usage of $y
$this->scope = $this->analyzeWhenValidNode($this->scope, $node->children['prop']);
$expr = $node->children['expr'];
- 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 normalizeDirectorySuppressions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function normalizeDirectorySuppressions(array $dir_suppressions): array
{
foreach ($dir_suppressions as $file_path => $rules) {
$new_file_path = self::normalizeDirectoryPathString($file_path);
- 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 hasUnknownTypeLoopNodeKinds
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function hasUnknownTypeLoopNodeKinds(Node $node): bool
{
switch ($node->kind) {
case ast\AST_CLOSURE:
case ast\AST_ARROW_FUNC:
- 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 getAnalyzeFunctionCallClosuresStatic
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function getAnalyzeFunctionCallClosuresStatic(): array
{
/**
* @param Closure(UnionType):int $checker returns _IS_IMPOSSIBLE/_IS_REDUNDANT/_IS_REASONABLE_CONDITION
* @param string $expected_type
- 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 analyzeIncDec
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeIncDec(Node $node): VariableTrackingScope
{
$var_node = $node->children['var'];
if ($var_node instanceof Node && $var_node->kind === ast\AST_VAR) {
$name = $var_node->children['name'];
- 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 getFlattenedClosures
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getFlattenedClosures(Closure $flattener): array
{
\ksort($this->closures);
$merged_closures = [];
foreach ($this->closures as $kind => $closure_list) {
- 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 getSuggestions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getSuggestions(string $name): array
{
if (!$this->strings || $name === '') {
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 visitMethodCall
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function visitMethodCall(Node $node): Context
{
if ($this->dim_depth >= 2) {
return $this->context;
}
- 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"