Showing 3,272 of 4,939 total issues
Function getIfExists
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getIfExists(string $key)
{
$path = $this->getPath($key);
if (!\file_exists($path)) {
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 addScopeToMergedLoopResult
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function addScopeToMergedLoopResult(
VariableTrackingScope $result,
VariableTrackingBranchScope $scope,
VariableGraph $graph
): void {
- 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 isPHPBinary
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function isPHPBinary(string $relative_path): bool
{
$cwd = \getcwd();
$absolute_path = "$cwd/$relative_path";
if (!\file_exists($absolute_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 addPromotedConstructorPropertyFromParam
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function addPromotedConstructorPropertyFromParam(
Clazz $class,
Method $method,
Parameter $parameter,
Node $parameter_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 visitCall
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function visitCall(Node $node): VariableTrackingScope
{
if (isset($node->dynamic_var_uses)) {
$this->handleDynamicVarUses($node, $node->dynamic_var_uses);
}
- 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 shouldSuppressIssue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function shouldSuppressIssue(
CodeBase $code_base,
Context $context,
string $issue_type,
int $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 checkIsSideEffectFreeLoopNode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function checkIsSideEffectFreeLoopNode(Node $node): void
{
// @phan-suppress-next-line PhanUndeclaredProperty
if (isset($node->has_loop_body_without_side_effects)) {
$this->side_effect_free_loop_nodes[] = $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 recordVariableUsage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function recordVariableUsage(string $name, Node $node, VariableTrackingScope $scope): void
{
if (!\array_key_exists($name, $this->variable_types)) {
// Set this to 0 to record that the variable was used somewhere
// (it will be overridden later if there are flags to set)
- 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 ensureDirectoryExists
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function ensureDirectoryExists(): bool
{
if ($this->directory_exists === null) {
$this->directory_exists = false;
if (!\is_dir($this->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 markVariablesAsReference
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function markVariablesAsReference(Node $expr): void
{
while (\in_array($expr->kind, [ast\AST_DIM, ast\AST_PROP], true)) {
$expr = $expr->children['expr'];
if (!$expr 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 extractAll
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function extractAll(string $fmt_str): array
{
// echo "format is $fmt_str\n";
$directives = [];
\preg_match_all(self::FORMAT_STRING_REGEX, $fmt_str, $matches, \PREG_SET_ORDER);
- 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 6 (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 global constant 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 setReturnTypeOfGenerator
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function setReturnTypeOfGenerator(FunctionInterface $func, Node $node): void
{
// Currently, there is no way to describe the types passed to
// a Generator in phpdoc.
// So, nothing bothers recording the types beyond \Generator.
- 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 analyzeParentConstructorCalled
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function analyzeParentConstructorCalled(
CodeBase $code_base,
Clazz $clazz
): void {
// Only look at classes configured to require a 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 addThisVariableToInternalScope
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function addThisVariableToInternalScope(
CodeBase $code_base,
Context $context,
Func $func
): void {
- 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 isUnpack
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function isUnpack(array $children): bool
{
foreach ($children as $child) {
if ($child instanceof Node) {
if ($child->kind === ast\AST_UNPACK) {
- 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 isVarargs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function isVarargs(CodeBase $code_base, FunctionInterface $method): bool
{
foreach ($method->alternateGenerator($code_base) as $alternate_method) {
foreach ($alternate_method->getParameterList() as $parameter) {
if ($parameter->isVariadic()) {
- 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 withNullOrUnsetArrayShapeTypes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function withNullOrUnsetArrayShapeTypes(UnionType $union_type, $dim_node, Context $context, bool $remove_offset): 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 warnAboutInvalidUnionType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function warnAboutInvalidUnionType(
Node $node,
Closure $is_valid_type,
UnionType $left,
UnionType $right,
- 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 getTypesFallback
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
final protected function getTypesFallback(Node $var_node, Context $context): ?UnionType
{
if ($var_node->kind !== ast\AST_VAR) {
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"