Showing 62 of 136 total issues
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
Line exceeds 80 characters; contains 117 characters Open
// In case the list of urls changes dynamically, lets just remove it from the source data to avoid unnecessary hash
- Exclude checks
Expected 1 space after "|"; 0 found Open
protected function getImageSize(string $url): bool|array {
- Exclude checks
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
Doc comment short description must start with a capital letter Open
* {@inheritDoc}
- Exclude checks
Line exceeds 80 characters; contains 82 characters Open
// CSV Imported content can be ignored since it's normally a one time thing.
- Exclude checks
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
Doc comment short description must start with a capital letter Open
* {@inheritDoc}
- Exclude checks
Remove error control operator '@' on line 123. Open
protected function getImageSize(string $url): bool|array {
try {
return @getimagesize($url);
}
catch (\Exception $e) {
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Missing class import via use statement (line '53', column '19'). Open
throw new \Exception('No Pager');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid assigning values to variables in if clauses and the like (line '57', column '13'). Open
public function loadOverrides($names) {
$overrides = [];
foreach ($names as $name) {
// Only override migration entities.
- 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 assigning values to variables in if clauses and the like (line '134', column '11'). Open
function stanford_migrate_entity_form_display_alter(EntityFormDisplayInterface $form_display, array $context) {
// We only care about nodes, but this could be expanded later if more entities
// are imported.
$node = \Drupal::routeMatch()->getParameter('node');
if ($context['entity_type'] != 'node' || !$node) {
- 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
The method postImport() has an NPath complexity of 1766. The configured NPath complexity threshold is 200. Open
public function postImport(MigrateImportEvent $event) {
$orphan_action = $this->getOrphanAction($event->getMigration());
// Migration doesn't have a orphan action, ignore it.
if (!$orphan_action) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
Avoid assigning values to variables in if clauses and the like (line '102', column '9'). Open
protected function isImageBigger($value) {
if (!is_string($value)) {
return FALSE;
}
- 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 assigning values to variables in if clauses and the like (line '156', column '9'). Open
protected function buildRow(MigrationInterface $migration) {
$row['label']['#markup'] = $migration->label();
$row['status']['#markup'] = $migration->getStatusLabel();
$row['imported']['#markup'] = $migration->getIdMap()->importedCount();
- 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
The method postImport() has 135 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function postImport(MigrateImportEvent $event) {
$orphan_action = $this->getOrphanAction($event->getMigration());
// Migration doesn't have a orphan action, ignore it.
if (!$orphan_action) {
- Exclude checks
Avoid assigning values to variables in if clauses and the like (line '62', column '15'). Open
public function loadOverrides($names) {
$overrides = [];
foreach ($names as $name) {
// Only override migration entities.
- 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
The method postImport() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10. Open
public function postImport(MigrateImportEvent $event) {
$orphan_action = $this->getOrphanAction($event->getMigration());
// Migration doesn't have a orphan action, ignore it.
if (!$orphan_action) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
syntax error, unexpected '|', expecting ';' or '{'
Open
protected function getImageSize(string $url): bool|array {
- Exclude checks
Argument 2 (allowable_tags)
is null
but \strip_tags()
takes string
Open
return strip_tags($value, $this->configuration['allowed'] ?? NULL);
- Exclude checks