SU-SWS/stanford_profile_helper

View on GitHub
src/EventSubscriber/EntityEventSubscriber.php

Summary

Maintainability
A
1 hr
Test Coverage
A
95%

File EntityEventSubscriber.php has 271 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 24. 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

        syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE)
        Open

          public function __construct(protected StanfordDefaultContentInterface $defaultContent, protected StateInterface $state, protected EntityTypeManagerInterface $entityTypeManager) {}

        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