src/Modules/Renderers/LoadContentRenderers.php
Avoid assigning values to variables in if clauses and the like (line '43', column '15'). Open
Open
public function __invoke(Project $project, OutputInterface $output)
{
if (! $contentRenderers = $this->configuration->get('content_renderers', null)) {
$output->writeln('[!] Your project\'s content renderers are miss-configured. Doing nothing and exiting.]');
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid excessively long variable names like $contentRendererFactory. Keep variable name length under 20. Open
Open
$contentRendererFactory = new ContentRendererFactory();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}