SU-SWS/stanford_migrate

View on GitHub
src/StanfordMigrate.php

Summary

Maintainability
A
2 hrs
Test Coverage
A
96%

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();

Severity: Minor
Found in src/StanfordMigrate.php - About 1 hr to fix

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());

Severity: Minor
Found in src/StanfordMigrate.php - About 35 mins to fix

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;

  /**
Severity: Minor
Found in src/StanfordMigrate.php by phpmd

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) {
Severity: Critical
Found in src/StanfordMigrate.php by phan

Avoid excessively long variable names like $batchExecuteMigrations. Keep variable name length under 20.
Open

  protected $batchExecuteMigrations = FALSE;
Severity: Minor
Found in src/StanfordMigrate.php by phpmd

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 $migrationPluginManager. Keep variable name length under 20.
Open

  public function __construct(protected EntityTypeManagerInterface $entityTypeManager, protected MigrationPluginManagerInterface $migrationPluginManager, LoggerChannelFactoryInterface $logger_factory) {
Severity: Minor
Found in src/StanfordMigrate.php by phpmd

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

Missing short description in doc comment
Open

  /**
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Line exceeds 80 characters; contains 82 characters
Open

      // CSV Imported content can be ignored since it's normally a one time thing.
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must end with a full stop
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must end with a full stop
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Missing parameter comment
Open

   * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migrationPluginManager
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Missing parameter comment
Open

   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Expected 1 blank line before function; 2 found
Open

  public function __construct(protected EntityTypeManagerInterface $entityTypeManager, protected MigrationPluginManagerInterface $migrationPluginManager, LoggerChannelFactoryInterface $logger_factory) {
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must start with a capital letter
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must start with a capital letter
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must end with a full stop
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must start with a capital letter
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Missing parameter comment
Open

   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must end with a full stop
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must end with a full stop
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Variable $type is undefined.
Open

          if ($type == $entity->getEntityTypeId()) {
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must start with a capital letter
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

There must be no blank line following an inline comment
Open

    // Finally run this migration.
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Doc comment short description must start with a capital letter
Open

   * {@inheritDoc}
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Expected 1 blank line after function; 2 found
Open

  }
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

Variable $type is undefined.
Open

          [, $type] = explode(':', $destination['plugin']);
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

There must be no blank line following an inline comment
Open

    // Finally run this migration.
Severity: Minor
Found in src/StanfordMigrate.php by phpcodesniffer

There are no issues that match your filters.

Category
Status