src/EventSubscriber/EntityEventSubscriber.php
File EntityEventSubscriber.php
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
Wontfix
<?php
namespace Drupal\stanford_profile_helper\EventSubscriber;
use Drupal\config_pages\ConfigPagesInterface;
EntityEventSubscriber
has 23 functions (exceeds 20 allowed). Consider refactoring. Wontfix
Wontfix
class EntityEventSubscriber implements EventSubscriberInterface {
use MessengerTrait;
use StringTranslationTrait;
Method preSaveNode
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function preSaveNode(NodeInterface $entity): void {
// Invalidate any search result cached so the updated/new content will be
// displayed for previously searched terms.
Cache::invalidateTags(['config:views.view.search']);
The class EntityEventSubscriber has a coupling between objects value of 23. Consider to reduce the number of dependencies under 13. Wontfix
Wontfix
class EntityEventSubscriber implements EventSubscriberInterface {
use MessengerTrait;
use StringTranslationTrait;
- 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
mixed $args
is not variadic in comment, but variadic in param (...$args)
Open
Open
* @param mixed $args
- Exclude checks
Argument 1 (event)
is \Drupal\core_event_dispatcher\Event\Entity\EntityInsertEvent
but \Drupal\stanford_profile_helper\EventSubscriber\EntityEventSubscriber::callIndividualEntityMethods()
takes \Drupal\core_event_dispatcher\Event\Entity\AbstractEntityEvent
defined at /code/src/EventSubscriber/EntityEventSubscriber.php:99
Open
Open
$this->callIndividualEntityMethods($event, 'insert');
- Exclude checks
Argument 1 (event)
is \Drupal\core_event_dispatcher\Event\Entity\EntityUpdateEvent
but \Drupal\stanford_profile_helper\EventSubscriber\EntityEventSubscriber::callIndividualEntityMethods()
takes \Drupal\core_event_dispatcher\Event\Entity\AbstractEntityEvent
defined at /code/src/EventSubscriber/EntityEventSubscriber.php:99
Open
Open
$this->callIndividualEntityMethods($event, 'update', $event->getOriginalEntity());
- Exclude checks
Argument 1 (event)
is \Drupal\core_event_dispatcher\Event\Entity\EntityDeleteEvent
but \Drupal\stanford_profile_helper\EventSubscriber\EntityEventSubscriber::callIndividualEntityMethods()
takes \Drupal\core_event_dispatcher\Event\Entity\AbstractEntityEvent
defined at /code/src/EventSubscriber/EntityEventSubscriber.php:99
Open
Open
$this->callIndividualEntityMethods($event, 'delete');
- Exclude checks
Argument 1 (event)
is \Drupal\core_event_dispatcher\Event\Entity\EntityPresaveEvent
but \Drupal\stanford_profile_helper\EventSubscriber\EntityEventSubscriber::callIndividualEntityMethods()
takes \Drupal\core_event_dispatcher\Event\Entity\AbstractEntityEvent
defined at /code/src/EventSubscriber/EntityEventSubscriber.php:99
Open
Open
$this->callIndividualEntityMethods($event, 'preSave');
- Exclude checks
Avoid excessively long variable names like $stanford_default_content. Keep variable name length under 20. Open
Open
public function __construct(StanfordDefaultContentInterface $stanford_default_content, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) {
- 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
Open
* {@inheritDoc}
- Exclude checks
Doc comment short description must end with a full stop Open
Open
* {@inheritDoc}
- Exclude checks