Dependency injection anti-patterns in Drupal

Whenever I have done an audit for a Drupal codebase, one of the first things I manually review and profile is dependency injection anti-patterns in custom code and any contributed modules used. The anti-pattern isn't for accessing services statically through \Drupal: service. These anti-patterns live within the class's __construct method.

mglaman.dev
@mglaman i have all those 3 wrong !!! 😂
@matthieu honestly it's only really bad if you have absurd forms (see commerce checkout form) or inefficient event subscribers
@mglaman i feel better ty ^^ i will keep doing anti pattern then 😆
@matthieu @mglaman the entity storage one can be nasty. I've seen poisoning of the hook cache if you do that before modules are loaded (eg in an inbound or outbound path processor). Can have flow on effects like field module hooks not being called and therefore missing field definitions 😬