SONARJAVA-6798 Collect dependencies from implicit single-constructor injection - #5950
Conversation
e764d04 to
cd56907
Compare
2331cc8 to
590df8d
Compare
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
590df8d to
aee21d4
Compare
asya-vorobeva
left a comment
There was a problem hiding this comment.
Theoretically speaking, we can mix single-constructor injection and @Autowired on field injection within the same Spring component, and Spring will successfully inject dependencies for both. E.g. the following configuration will successfully autowire 2 beans:
@Component
public class UserService {
// Injected via Constructor
private final UserRepository userRepository;
// Injected via Field Injection after instantiation
@Autowired
private NotificationService notificationService;
// Single constructor: Spring automatically autowires 'userRepository'
public UserService(UserRepository userRepository) {
this.userRepository = userRepository;
}
}
Code Review ✅ Approved 2 resolved / 2 findingsCollects dependencies from implicit single-constructor injection and properly skips them when an ✅ 2 resolved✅ Quality: New BeanDependency record is dead/unused code
✅ Bug: Implicit constructor injection over-collects when an @Autowired constructor exists
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|
…injection (#5950) Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>



Summary by Gitar
BeanDefinitionGathererThis will update automatically on new commits.