Skip to content

Small fixes in BugInstance and BugInstanceMatcher #3187

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

Merged
merged 6 commits into from
Nov 13, 2024

Conversation

JuditKnoll
Copy link
Collaborator

This PR should not cause any change in functionality.
I haven't added any changelog entry, since I don't think this type of fix needs it.

Comment on lines -1047 to -1048
* see http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.
* html#14152 <br>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page doesn't exist anymore.

Comment on lines -1049 to +1041
* or http://www.murrayc.com/learning/java/java_classfileformat.shtml#
* TypeDescriptors
* see <a href="https://www.murrayc.com/permalink/1998/03/13/the-java-class-file-format/#TypeDescriptors">TypeDescriptors</a>.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link forwards to the new link.

Comment on lines -1620 to +1611
SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(visitor.getClassContext(),
visitor, pc);
if (sourceLineAnnotation != null) {
add(sourceLineAnnotation);
}
add(SourceLineAnnotation.fromVisitedInstruction(visitor.getClassContext(), visitor, pc));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these cases, the variable can never be null, so the null check is not necessary.

Comment on lines -1883 to +1845
return getBugPattern().getLongDescription().replaceAll("BUG_PATTERN", type);
return getBugPattern().getLongDescription().replace("BUG_PATTERN", type);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument doesn't contain any regex, so we can use replace() instead of replaceAll().

String simpleName = fullName.substring(startDot != -1 ? startDot : 0, endDollar != -1 ? endDollar : fullName.length());
String simpleNameInner = fullName.substring(startDot != -1 ? startDot : 0, fullName.length());
String simpleName = fullName.substring(startDot, endDollar != -1 ? endDollar : fullName.length());
String simpleNameInner = fullName.substring(startDot);
Copy link
Collaborator Author

@JuditKnoll JuditKnoll Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of startDot can never be -1, since the smallest value of lastIndexOf() is -1, but there is a +1 (see line 110).

@JuditKnoll JuditKnoll marked this pull request as ready for review November 6, 2024 15:36
@hazendaz
Copy link
Member

hazendaz commented Nov 7, 2024

This PR should not cause any change in functionality. I haven't added any changelog entry, since I don't think this type of fix needs it.

Since appendText of comma is a fix to the description, I think a change log for that would be nice. Otherwise agree rest is just cleanup.

@JuditKnoll
Copy link
Collaborator Author

This PR should not cause any change in functionality. I haven't added any changelog entry, since I don't think this type of fix needs it.

Since appendText of comma is a fix to the description, I think a change log for that would be nice. Otherwise agree rest is just cleanup.

Thanks, you are absolutely right. Added a changelog entry to mention this.

continue;
}
if (b instanceof SourceLineAnnotation && ((SourceLineAnnotation) b).isUnknown()) {
if (primaryAnnotations.contains(b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, flip the logic to "if not any of these then add".

@hazendaz hazendaz self-assigned this Nov 13, 2024
@hazendaz hazendaz added this to the SpotBugs 4.9.0 milestone Nov 13, 2024
@hazendaz hazendaz merged commit 466f99b into spotbugs:master Nov 13, 2024
15 checks passed
@JuditKnoll JuditKnoll deleted the fixes branch November 14, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants