Showing 3,272 of 4,939 total issues
Function getReturnTypes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function getReturnTypes(Context $context, $node, int $return_lineno): \Generator
{
if (!($node instanceof Node)) {
if (null === $node) {
yield $return_lineno => [VoidType::instance(false)->asRealUnionType(), 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 computeStatusOfSwitchList
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function computeStatusOfSwitchList(Node $node): int
{
$switch_stmt_case_nodes = $node->children ?? [];
if (\count($switch_stmt_case_nodes) === 0) {
return self::STATUS_PROCEED;
- 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 updateVariableWithConditionalFilter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
final protected function updateVariableWithConditionalFilter(
Node $var_node,
Context $context,
Closure $should_filter_cb,
Closure $filter_union_type_cb,
- 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 handleParseError
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function handleParseError(
CodeBase $code_base,
Context $context,
string $file_path,
string $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 checkForInfiniteRecursion
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function checkForInfiniteRecursion(Node $node, FunctionInterface $method): void
{
$argument_list_node = $node->children['args'];
$kind = $node->kind;
if ($kind === ast\AST_METHOD_CALL || $kind === ast\AST_NULLSAFE_METHOD_CALL) {
- 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 warnOverridingFinalMethod
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function warnOverridingFinalMethod(CodeBase $code_base, Method $method, Clazz $class, Method $o_method): void
{
if ($method->isFromPHPDoc()) {
// TODO: Track phpdoc methods separately from real methods
if ($class->checkHasSuppressIssueAndIncrementCount(Issue::AccessOverridesFinalMethodPHPDoc)) {
- 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 visitConstDecl
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitConstDecl(Node $node): Context
{
foreach ($node->children as $child_node) {
if (!$child_node instanceof Node) {
throw new AssertionError('expected const element to be a 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 getPrinter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getPrinter(?string $type, OutputInterface $output): IssuePrinterInterface
{
switch ($type) {
case 'codeclimate':
$printer = new CodeClimatePrinter();
- 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 interfaceBaseClauseToNode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function interfaceBaseClauseToNode(?\Microsoft\PhpParser\Node\InterfaceBaseClause $node): ?\ast\Node
{
if (!$node instanceof PhpParser\Node\InterfaceBaseClause) {
// TODO: real placeholder?
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 visitStaticCall
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitStaticCall(Node $node): UnionType
{
['class' => $class_node, 'method' => $method_name] = $node->children;
if (!\is_string($method_name) || !($class_node instanceof Node) || $class_node->kind !== ast\AST_NAME) {
// Give up on dynamic calls
- 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 normalizeStatementList
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function normalizeStatementList(array $statements): array
{
$modified = false;
$new_statements = [];
foreach ($statements as $stmt) {
- 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 visitClassNameNode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function visitClassNameNode(Node $node): UnionType
{
$kind = $node->kind;
// Anonymous class of form `new class { ... }`
if ($kind === \ast\AST_CLASS
- 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 unionTypeFromLiteralOrConstant
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function unionTypeFromLiteralOrConstant(CodeBase $code_base, Context $context, $node): ?UnionType
{
if ($node instanceof Node) {
// TODO: There are a lot more types of expressions that have known union types that this doesn't handle.
// Maybe callers should call something else if this fails (e.g. it's useful for them to know if an expression becomes a string)
- 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 getTraitAdaptationsMap
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getTraitAdaptationsMap(array $trait_fqsen_list): array
{
if (!($this->node instanceof Node)) {
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 getVariableStrict
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getVariableStrict(): Variable
{
$node = $this->node;
if (!($node instanceof Node)) {
throw new AssertionError('$this->node must be a 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 getFunctionLikeFromDynamicExpression
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function getFunctionLikeFromDynamicExpression(): \Generator
{
$code_base = $this->code_base;
$context = $this->context;
$expression = $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 getLinesToDelete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function getLinesToDelete(string $file_contents): array
{
$paths = [];
foreach (explode("\n", $file_contents) as $line) {
$line = trim($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
Function generateCssForColor
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function generateCssForColor(string $color): string
{
$combination = [];
foreach (explode(',', $color) as $color_component) {
if ($color_component === 'none') {
- 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 computeEditSetToDeleteComment
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function computeEditSetToDeleteComment(string $file_contents, Token $comment_token): FileEditSet
{
// get the byte where the `)` of the argument list ends
$last_byte_index = $comment_token->getEndPosition();
$first_byte_index = $comment_token->start;
- 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 getAnalyzeFunctionCallClosures
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getAnalyzeFunctionCallClosures(CodeBase $code_base): array
{
$warn_remove_debug_call = static function (CodeBase $code_base, Context $context, FunctionInterface $function): void {
self::emitIssue(
$code_base,
- 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"