-
Notifications
You must be signed in to change notification settings - Fork 15
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
style: Fix more sonar issues with core #1131
Conversation
private final String message; | ||
|
||
public ApplicationException(String msg, Object... params) { | ||
super(msg, MessageFormatter.getThrowableCandidate(params)); | ||
this.params = params; | ||
this.message = (params != null && params.length != 0) | ||
? MessageFormatter.arrayFormat(super.getMessage(), params).getMessage() | ||
: super.getMessage(); | ||
} | ||
|
||
@Override | ||
public synchronized String getMessage() { | ||
if (formattedMessage == null) { | ||
formattedMessage = MessageFormatter.arrayFormat(super.getMessage(), params).getMessage(); | ||
} | ||
return formattedMessage; | ||
public String getMessage() { | ||
return message; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sonar complained about the field formattedMessage
.
However, the code itself was, for some reason, initializing the formatted message inside the getMessage()
instead of the constructor. Also, params
could be null
there, which would lead to a NullPointerException
, so I guarded against that.
3c9547e
to
2869c4e
Compare
List<Dependency> updatedDependencies = new ArrayList<>(bom.getDependencies().size()); | ||
for (Dependency dependency : bom.getDependencies()) { | ||
updateDependencyRef(dependency, oldRef, newRef); | ||
updatedDependencies.add(dependency); | ||
} | ||
bom.setDependencies(new ArrayList<>(updatedDependencies)); | ||
bom.setDependencies(updatedDependencies); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TreeSet
was used for some reason, but the Dependency
is not sortable, and ArrayList
was the API type anyway.
public static List<String> computeNVRFromContainerManifest(JsonNode jsonNode) { | ||
Bom bom = fromJsonNode(jsonNode); | ||
if (bom == null || bom.getComponents() == null || bom.getComponents().isEmpty()) { | ||
return null; | ||
return List.of(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converted from primitive array to List
, but it may be better to have an NVR
type.
No description provided.