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

style: Fix more sonar issues with core #1131

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

dwalluck
Copy link
Contributor

@dwalluck dwalluck commented Feb 7, 2025

No description provided.

Comment on lines +23 to +34
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;
Copy link
Contributor Author

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.

@dwalluck dwalluck force-pushed the sonar-core branch 11 times, most recently from 3c9547e to 2869c4e Compare February 11, 2025 15:23
Comment on lines +470 to +475
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);
Copy link
Contributor Author

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.

Comment on lines +805 to +808
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();
Copy link
Contributor Author

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.

@dwalluck dwalluck merged commit 04cd15e into project-ncl:main Feb 17, 2025
7 checks passed
@dwalluck dwalluck deleted the sonar-core branch February 17, 2025 13: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
Development

Successfully merging this pull request may close these issues.

2 participants