Find injected fields used by only one @Bean method

Proprietary

Marks the name of a field injected with @Autowired, @javax.inject.Inject or @jakarta.inject.Inject in a class directly annotated @Configuration, when exactly one method of that class refers to it and that method is a @Bean method. SonarQube reports these because the dependency could be a parameter of that method instead. The field is only marked, not moved: moving it can change when and whether Spring injects it, for example when the class also declares early post processors or scoped beans, or takes part in a circular reference. Fields declared @Autowired(required = false) with an initializer are not marked. Uses in constructors, initializer blocks, field initializers and nested classes are not counted, and classes that are configuration classes only through a meta-annotation such as @SpringBootApplication are not searched. Test sources are not searched.

io.moderne.java.spring.framework.FindInjectedFieldUsedByOneBeanMethod
mod run . --recipe=io.moderne.java.spring.framework.FindInjectedFieldUsedByOneBeanMethod

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.