Showing 3,272 of 4,939 total issues
Function afterAnalyzeFile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function afterAnalyzeFile(CodeBase $code_base, Context $context, string $file_contents, Node $node): void
{
$path = $context->getFile();
if (Paths::isAbsolutePath($path) || \strpos($path, '../') !== false) {
CLI::printToStderr("phantasm: Skipping '$path': Only modifying files within the project directory\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
Method emit
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $issue_type,
string $issue_message_fmt,
array $issue_message_args = [],
int $severity = Issue::SEVERITY_NORMAL,
int $remediation_difficulty = Issue::REMEDIATION_B,
Function visitVar
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function visitVar(Node $node): VariableTrackingScope
{
$name = $node->children['name'];
if (\is_string($name)) {
self::$variable_graph->recordVariableUsage($name, $node, $this->scope);
- 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 shouldSuppressIssue
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
string $issue_type,
int $lineno,
array $parameters,
Method shouldSuppressIssue
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
string $issue_type,
int $lineno,
array $parameters,
Avoid deeply nested control flow statements. Open
if ($class->isTrait()) {
$issue_type = Issue::AbstractStaticMethodCallInTrait;
}
Function analyzeShortCircuitingOr
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeShortCircuitingOr($left, $right): Context
{
// Aside: If left/right is not a node, left/right is a literal such as a number/string, and is either always truthy or always falsey.
// Inside of this conditional may be dead or redundant code.
if (!($left 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 analyzeShortCircuitingAnd
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function analyzeShortCircuitingAnd($left, $right): Context
{
// Analyze expressions such as if (!(is_string($x) || is_int($x)))
// which would be equivalent to if (!is_string($x)) { if (!is_int($x)) { ... }}
- 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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
Node $assignment_node,
UnionType $right_type,
int $dim_depth = 0,
Method warnAboutInvalidUnionType
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Node $node,
Closure $is_valid_type,
UnionType $left,
UnionType $right,
string $left_issue_type,
Avoid deeply nested control flow statements. Open
if ($this->context->isInGlobalScope()) {
return $this->updateTargetWithType($assign_op_node, $get_type);
}
Method maybeWarnProvidingUnusedParameter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
Context $context,
int $lineno,
FunctionInterface $method,
Parameter $parameter,
Function checkIsDeprecatedOrInternal
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function checkIsDeprecatedOrInternal(CodeBase $code_base, Context $context, FunctionInterface $method): void
{
// Special common cases where we want slightly
// better multi-signature error messages
if ($method->isPHPInternal()) {
- 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 createNegationCallbackMap
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function createNegationCallbackMap(): array
{
/** @param list<Node|mixed> $unused_args */
$remove_null_cb = static function (CodeBase $unused_code_base, Context $unused_context, Variable $variable, array $unused_args): void {
$variable->setUnionType($variable->getUnionType()->nonNullableClone());
- 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 withSetArrayShapeTypes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function withSetArrayShapeTypes(UnionType $union_type, $dim_node, Context $context, bool $non_nullable): UnionType
{
$dim_value = $dim_node instanceof Node ? (new ContextNode($this->code_base, $context, $dim_node))->getEquivalentPHPScalarValue() : $dim_node;
// TODO: detect and warn about null
if (!\is_scalar($dim_value)) {
- 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 withNonFalseyArrayShapeTypes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function withNonFalseyArrayShapeTypes(Variable $variable, $dim_node, Context $context, bool $non_nullable): Context
{
$dim_value = $dim_node instanceof Node ? (new ContextNode($this->code_base, $this->context, $dim_node))->getEquivalentPHPScalarValue() : $dim_node;
// TODO: detect and warn about null
if (!\is_scalar($dim_value)) {
- 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 updateVariableWithNewType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
final protected function updateVariableWithNewType(
Node $var_node,
Context $context,
UnionType $new_union_type,
bool $suppress_issues,
- 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 tryToAssignPHPDocTypeToParameter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
CodeBase $code_base,
FunctionInterface $method,
int $i,
Parameter $parameter,
UnionType $real_param_type,
Function analyzeOverrideSignature
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private static function analyzeOverrideSignature(
CodeBase $code_base,
Method $method
): void {
if (!Config::getValue('analyze_signature_compatibility')) {
- 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 updateDimExpressionWithConditionalFilter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Node $node,
Context $context,
Closure $should_filter_cb,
Closure $filter_union_type_cb,
bool $suppress_issues,