Skip to content

Commit

Permalink
fix: lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
acke committed Jan 30, 2025
1 parent befa9dd commit 864ad64
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ public class SnykExtendedLanguageClient extends LanguageClientImpl {
private Object chSyncObject = new Object();
private CommandHandler commandHandler;

private static SnykExtendedLanguageClient instance = null;
private static SnykExtendedLanguageClient instance;

public SnykExtendedLanguageClient() {
super();
instance = this;
//TODO, fix this; Identifies a possible unsafe usage of a static field.
instance = this; //NOPMD
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
registerPluginInstalledEventTask();
registerRefreshFeatureFlagsTask();
Expand Down Expand Up @@ -376,6 +377,8 @@ public void snykScan(SnykScanParam param) {
productTreeNode.setErrorMessage(param.getErrorMessage());
}
break;
default:
break;
}
setNodeState(param.getStatus(), affectedProductTreeNodes, issueCache);
this.toolView.refreshBrowser(param.getStatus());
Expand Down Expand Up @@ -435,7 +438,7 @@ private void setNodeState(String status, Set<ProductTreeNode> affectedProductTre
if (affectedProductTreeNodes.isEmpty()) {
return;
}
var nodeText = "";
String nodeText;

if (status.equals(SCAN_STATE_IN_PROGRESS)) {
nodeText = NODE_TEXT_SCANNING;
Expand Down Expand Up @@ -535,19 +538,21 @@ public void publishDiagnostics316(PublishDiagnostics316Param param) {
populateIssueCache(param, filePath);
}

private void populateFileAndIssueNodes(ProductTreeNode productTreeNode,
SnykIssueCache issueCache) {
private void populateFileAndIssueNodes(ProductTreeNode productTreeNode, SnykIssueCache issueCache) {
var cacheHashMap = issueCache.getCacheByDisplayProduct(productTreeNode.getProduct());
ArrayList<Issue> issuesList = new ArrayList<>(); // Reusable ArrayList

Check warning on line 543 in plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Avoid using implementation types like 'ArrayList'; use the interface instead

Excessive coupling to implementation types (e.g., `HashSet`) limits your ability to use alternate implementations in the future as requirements change. Whenever available, declare variables and parameters using a more general type (e.g, `Set`). This rule reports uses of concrete collection types. User-defined types that should be treated the same as interfaces can be configured with the property `allowedTypes`. LooseCoupling (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.9.0/pmd_rules_java_bestpractices.html#loosecoupling

Check warning

Code scanning / PMD

Avoid using implementation types like 'ArrayList'; use the interface instead Warning

Avoid using implementation types like 'ArrayList'; use the interface instead
for (var kv : cacheHashMap.entrySet()) {
var fileName = kv.getKey();
var issues = new ArrayList<>(kv.getValue());
issuesList.clear(); // Clear the list instead of creating a new one
issuesList.addAll(kv.getValue());

if (issues.isEmpty())
if (issuesList.isEmpty())
continue;
FileTreeNode fileNode = new FileTreeNode(fileName);

FileTreeNode fileNode = new FileTreeNode(fileName); //NOPMD
toolView.addFileNode(productTreeNode, fileNode);
for (Issue issue : issues) {
toolView.addIssueNode(fileNode, new IssueTreeNode(issue));
for (Issue issue : issuesList) {
toolView.addIssueNode(fileNode, new IssueTreeNode(issue)); //NOPMD
}
}
}
Expand Down Expand Up @@ -587,6 +592,8 @@ private void populateIssueCache(PublishDiagnostics316Param param, String filePat
case SCAN_PARAMS_IAC:
issueCache.addIacIssues(filePath, issueList);
break;
default:
break;
}
}

Expand Down

0 comments on commit 864ad64

Please sign in to comment.