Function deleteEntityFromMigration
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
public function deleteEntityFromMigration(EntityInterface $entity): void {
foreach ($this->getMigrationList() as $migrations) {
foreach ($migrations as $migration) {
$destination = $migration->getDestinationConfiguration();
- 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 getNodesMigration
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring. Open
public function getNodesMigration(NodeInterface $node): ?MigrationEntityInterface {
// Use a static variable so that it doesn't look up the migrations multiple
// times.
$node_migration = &drupal_static(__CLASS__ . __FUNCTION__ . '_' . $node->id());
- 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
The class StanfordMigrate has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13. Open
class StanfordMigrate implements StanfordMigrateInterface {
use MessengerTrait;
/**
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE)
Open
public function __construct(protected EntityTypeManagerInterface $entityTypeManager, protected MigrationPluginManagerInterface $migrationPluginManager, LoggerChannelFactoryInterface $logger_factory) {
- Exclude checks
Avoid excessively long variable names like $migrationPluginManager. Keep variable name length under 20. Open
public function __construct(protected EntityTypeManagerInterface $entityTypeManager, protected MigrationPluginManagerInterface $migrationPluginManager, LoggerChannelFactoryInterface $logger_factory) {
- 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++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $batchExecuteMigrations. Keep variable name length under 20. Open
protected $batchExecuteMigrations = FALSE;
- 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++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Doc comment short description must start with a capital letter Open
* {@inheritDoc}
- Exclude checks
There must be no blank line following an inline comment Open
// Finally run this migration.
- Exclude checks
Expected 1 blank line before function; 2 found Open
public function __construct(protected EntityTypeManagerInterface $entityTypeManager, protected MigrationPluginManagerInterface $migrationPluginManager, LoggerChannelFactoryInterface $logger_factory) {
- Exclude checks
Doc comment short description must start with a capital letter Open
* {@inheritDoc}
- Exclude checks
Missing parameter comment Open
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
- Exclude checks
Missing parameter comment Open
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
- Exclude checks
Expected 1 blank line after function; 2 found Open
}
- Exclude checks
Doc comment short description must start with a capital letter Open
* {@inheritDoc}
- Exclude checks
Missing parameter comment Open
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migrationPluginManager
- Exclude checks
Doc comment short description must start with a capital letter Open
* {@inheritDoc}
- Exclude checks
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
Variable $type is undefined. Open
[, $type] = explode(':', $destination['plugin']);
- Exclude checks
Doc comment short description must start with a capital letter Open
* {@inheritDoc}
- Exclude checks
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
There must be no blank line following an inline comment Open
// Finally run this migration.
- Exclude checks
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
Variable $type is undefined. Open
if ($type == $entity->getEntityTypeId()) {
- Exclude checks
Doc comment short description must end with a full stop Open
* {@inheritDoc}
- Exclude checks
Missing short description in doc comment Open
/**
- 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