Skip to content

Add a field annotation when looking for FS_BAD_DATE_FORMAT_FLAG_COMBO#3868

Merged
gtoison merged 6 commits intospotbugs:masterfrom
gtoison:issue-3838
Jan 15, 2026
Merged

Add a field annotation when looking for FS_BAD_DATE_FORMAT_FLAG_COMBO#3868
gtoison merged 6 commits intospotbugs:masterfrom
gtoison:issue-3838

Conversation

@gtoison
Copy link
Copy Markdown
Contributor

@gtoison gtoison commented Jan 1, 2026

When declaring and initialising a field at the same time the FS_BAD_DATE_FORMAT_FLAG_COMBO bug instances found are not associated with the field.
This is because the problematic code is in the <init> method, not on the field itself.

This PR adds a class keeping track of the bug instances according to the PC (and next PC) where they were detected.
When the field is assigned we check if a bug instance was found on the previous PC.
In that case we add a field annotation.

Now that the bug has a field annotation, it is suppressed by field level annotation.

@gtoison gtoison self-assigned this Jan 1, 2026
Keep track of the PC (and next PC) where DateFormatStringChecker detects
bugs, when a field is initialized on the next PC add a field annotation
to the bug instance.
@gtoison gtoison merged commit 124e530 into spotbugs:master Jan 15, 2026
26 of 27 checks passed
@hazendaz hazendaz added this to the Spotbugs 4.10.0 milestone Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suppression of bad time format on variable doesn't work

4 participants