Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FPs with multiple initialization of Singletons #2951

Merged
merged 5 commits into from Apr 27, 2024

Conversation

JuditKnoll
Copy link
Collaborator

This PR fixes #2934.
The MultipleInstantiationsOfSingletons detector is a bit eagerly considers classes as singletons. With this change, the detector

  • accepts enums with 1 elements as well, not only those with 0 elements,
  • recognizes if instance field is assigned a specific inner child instance, not the containing class itself, and does not consider these classes as singletons,
  • does not consider singletons abstract classes or interfaces,
  • can find the instance getter method more accurately.

@JuditKnoll JuditKnoll marked this pull request as draft April 19, 2024 14:42
@JuditKnoll JuditKnoll marked this pull request as ready for review April 22, 2024 16:34
@hazendaz hazendaz self-assigned this Apr 27, 2024
@hazendaz hazendaz added this to the Spotbugs 4.8.5 milestone Apr 27, 2024
@hazendaz hazendaz merged commit bebfdf8 into spotbugs:master Apr 27, 2024
15 checks passed
@JuditKnoll JuditKnoll deleted the singleton_fix branch April 29, 2024 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants