Skip to content

Small fixes in BugInstance and BugInstanceMatcher#3187

Merged
hazendaz merged 6 commits intospotbugs:masterfrom
JuditKnoll:fixes
Nov 13, 2024
Merged

Small fixes in BugInstance and BugInstanceMatcher#3187
hazendaz merged 6 commits intospotbugs:masterfrom
JuditKnoll:fixes

Conversation

@JuditKnoll
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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