GlobalDrupalSniff's use of $baseClasses is insufficient and fails to detect relevant cases

Created on 4 December 2020, almost 4 years ago
Updated 25 October 2024, about 1 month ago

Problem/Motivation

Because GlobalDrupalSniff only checks the base class extended by the given class, it fails to detect a variety of instances where global Drupal calls are "bad." This might be a case where the base class simply isn't listed, such as any generic plugin that would extend PluginBase, or one that extends a class that extends one of the listed $baseClasses, or simply a generic service implementation that does not extend any other classes.

Steps to reproduce

Run DrupalPractice against any class that would go into /src/ that does not explicitly extend one of the classes listed in $baseClasses.

Proposed resolution

Replace the $baseClasses check with one that simply checks if this class's file resides in /src/, and add additional help text to the $warning to suggest that Plugins should implement ContainerFactoryPluginInterface.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Coder Sniffer

Created by

πŸ‡ΊπŸ‡ΈUnited States mrweiner

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024