src/Phan/IssueInstance.php
The method IssueInstance::__construct() calls the typical debug function debug_print_backtrace() which is mostly only used during development. Open
Open
\debug_print_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
- Read upRead up
- Exclude checks
DevelopmentCodeFragment
Since: 2.3.0
Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.
Example
class SuspectCode {
public function doSomething(array $items)
{
foreach ($items as $i => $item) {
// …
if ('qafoo' == $item) var_dump($i);
// …
}
}
}
Source https://phpmd.org/rules/design.html#developmentcodefragment
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
Issue $issue,
string $file,
int $line,
array $template_parameters,
Suggestion $suggestion = null,
Function normalizeTemplateParameters
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private static function normalizeTemplateParameters(array $template_parameters): array
{
foreach ($template_parameters as $i => $parameter) {
if ($parameter instanceof UnionType) {
$parameter = $parameter->__toString();
- 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"