SU-SWS/stanford_profile_helper

View on GitHub
src/EventSubscriber/EntityEventSubscriber.php

Summary

Maintainability
A
1 hr
Test Coverage
B
81%

File EntityEventSubscriber.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

namespace Drupal\stanford_profile_helper\EventSubscriber;

use Drupal\config_pages\ConfigPagesInterface;
Severity: Minor
Found in src/EventSubscriber/EntityEventSubscriber.php - About 2 hrs to fix

    EntityEventSubscriber has 23 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    class EntityEventSubscriber implements EventSubscriberInterface {
    
      use MessengerTrait;
      use StringTranslationTrait;
    
    
    Severity: Minor
    Found in src/EventSubscriber/EntityEventSubscriber.php - About 2 hrs to fix

      Method preSaveNode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      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']);
      
      
      Severity: Minor
      Found in src/EventSubscriber/EntityEventSubscriber.php - About 1 hr to fix

        The class EntityEventSubscriber has a coupling between objects value of 23. Consider to reduce the number of dependencies under 13.
        Wontfix

        class EntityEventSubscriber implements EventSubscriberInterface {
        
          use MessengerTrait;
          use StringTranslationTrait;
        
        

        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

           * @param mixed $args

        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

            $this->callIndividualEntityMethods($event, 'insert');

        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

            $this->callIndividualEntityMethods($event, 'update', $event->getOriginalEntity());

        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

            $this->callIndividualEntityMethods($event, 'delete');

        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

            $this->callIndividualEntityMethods($event, 'preSave');

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

          public function __construct(StanfordDefaultContentInterface $stanford_default_content, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) {

        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}

        Doc comment short description must end with a full stop
        Open

           * {@inheritDoc}

        There are no issues that match your filters.

        Category
        Status