Why does SonarQube flag Autowired field injection as a bug (S3759)

Hi folks, I was just wondering that why SonarQube raises an error when I try to use Autoired instead of dependency injection using constructor?

There seems to be a bias towards the constructor injection, but an insight would be useful!

@Service
public class MyService {
    @Autowired
    private SomeDependency dependency;  // ← flagged by SonarQube
}

Hi,

Welcome to the community!

Can you provide the context where you’re seeing this? SonarQube Cloud? SonarQube Server or Community Build? And if so, what version? SonarQube for IDE? And if so, flavor and version?

 
Thx,
Ann