SU-SWS/stanford_migrate

View on GitHub

Showing 65 of 139 total issues

Expected 1 space before "|"; 0 found
Open

  protected function getImageSize(string $url): bool|array {

Doc comment short description must end with a full stop
Open

   * {@inheritDoc}

Missing short description in doc comment
Open

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

TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
Open

  if ($variables['element']['#third_party_settings']['stanford_migrate']['readonly'] ?? false) {
Severity: Minor
Found in stanford_migrate.module by phpcodesniffer

Expected 1 space after "|"; 0 found
Open

  protected function getSourceData(string $url, string|int $item_selector = ''): array {

Variable $width is undefined.
Open

      [$width, $height] = $size;

Expected 1 blank line after function; 2 found
Open

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

Missing interface doc comment
Open

interface StanfordMigrateInterface {

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
Severity: Minor
Found in stanford_migrate.module by phpcodesniffer

Doc comment short description must start with a capital letter
Open

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

Line exceeds 80 characters; contains 108 characters
Open

  // Oauth2 authentication adds a token query parameter into the data urls that changes frequently. Since it
Severity: Minor
Found in stanford_migrate.module by phpcodesniffer

Missing class import via use statement (line '53', column '19').
Open

        throw new \Exception('No Pager');

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

Remove error control operator '@' on line 123.
Open

  protected function getImageSize(string $url): bool|array {
    try {
      return @getimagesize($url);
    }
    catch (\Exception $e) {

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

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.

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 '62', column '15').
Open

  public function loadOverrides($names) {
    $overrides = [];
    foreach ($names as $name) {

      // Only override migration entities.

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 '102', column '9').
Open

  protected function isImageBigger($value) {
    if (!is_string($value)) {
      return FALSE;
    }

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) {

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

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 '133', 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) {
Severity: Minor
Found in stanford_migrate.module by phpmd

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) {

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

Severity
Category
Status
Source
Language