Skip to content

Commit fff3029

Browse files
committed
tidy: fix linter warnings
1 parent 716313d commit fff3029

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

plugin/src/main/java/io/snyk/eclipse/plugin/analytics/TaskProcessor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
import java.util.Queue;
56
import java.util.concurrent.CompletableFuture;
67
import java.util.concurrent.ConcurrentLinkedQueue;
78
import java.util.function.Consumer;
@@ -17,7 +18,7 @@
1718
*/
1819
public class TaskProcessor {
1920
// left = taskToExecute, right = callback function
20-
private final ConcurrentLinkedQueue<Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>>> taskQueue = new ConcurrentLinkedQueue<>();
21+
private final Queue<Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>>> taskQueue = new ConcurrentLinkedQueue<>();
2122

2223
private TaskProcessor() {
2324
CompletableFuture.runAsync(() -> {
@@ -39,6 +40,8 @@ public static TaskProcessor getInstance() {
3940
}
4041

4142
private void start() {
43+
final List<Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>>> copyForSending = new ArrayList<>();
44+
4245
while (true) {
4346
String authToken = Preferences.getInstance().getAuthToken();
4447
SnykExtendedLanguageClient lc = SnykExtendedLanguageClient.getInstance();
@@ -50,8 +53,9 @@ private void start() {
5053
}
5154
continue;
5255
}
53-
List<Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>>> copyForSending = new ArrayList<>(
54-
taskQueue);
56+
57+
copyForSending.clear(); // Clear the list before reuse
58+
copyForSending.addAll(taskQueue); // Add all elements from taskQueue
5559

5660
for (Pair<Consumer<SnykExtendedLanguageClient>, Consumer<Void>> event : copyForSending) {
5761
try {

plugin/src/main/java/io/snyk/eclipse/plugin/html/StaticPageHtmlProvider.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,16 @@ public String getSummaryInitHtml() {
161161
if (logger == null) {
162162
logger = Platform.getLog(getClass());
163163
}
164-
StringBuilder content = new StringBuilder();
165164

165+
StringBuilder content = new StringBuilder();
166166
try (InputStream inputStream = getClass().getResourceAsStream("/ui/html/ScanSummaryInit.html");
167167
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
168168

169-
String line;
170-
while ((line = reader.readLine()) != null) {
171-
content.append(line).append("\n");
169+
String line = reader.readLine();
170+
while (line != null) {
171+
// Process the line here
172+
content.append(line).append(System.lineSeparator());
173+
line = reader.readLine();
172174
}
173175
} catch (IOException e) {
174176
SnykLogger.logError(e);

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BaseBranchDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class BaseBranchDialog {
2525
public BaseBranchDialog() {
2626
}
2727

28-
public void open(Display display, Path projectPath, String[] localBranches) {
28+
public void open(Display display, Path projectPath, String... localBranches) {
2929
Shell shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
3030
shell.setText("Choose base branch for net-new issues scanning");
3131
shell.setLayout(new GridLayout(1, false));

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/BrowserHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
@SuppressWarnings("restriction")
3636
public class BrowserHandler {
37+
private static final int validNumberOfArguments = 5;
3738
private Browser browser;
3839
private String initScript = "";
3940

@@ -45,7 +46,7 @@ public void initialize() {
4546
new BrowserFunction(browser, "openInEditor") {
4647
@Override
4748
public Object function(Object[] arguments) {
48-
if (arguments.length != 5) {
49+
if (arguments.length != validNumberOfArguments) {
4950
return null;
5051
}
5152
String filePath = (String) arguments[0];
@@ -165,7 +166,7 @@ public CompletableFuture<Void> updateBrowserContent(TreeNode node) {
165166
}
166167

167168
private BaseHtmlProvider getHtmlProvider(TreeNode node) {
168-
var product = "";
169+
String product;
169170
if (node instanceof IssueTreeNode) {
170171
product = ((ProductTreeNode) node.getParent().getParent()).getProduct();
171172
} else if (node instanceof ProductTreeNode) {

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/CollapseTreeHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
1313

1414
String commandId = event.getCommand().getId();
1515

16-
switch (commandId) {
17-
case "io.snyk.eclipse.plugin.commands.TreeCollapse":
16+
String treeCollapse = "io.snyk.eclipse.plugin.commands.TreeCollapse";
17+
String treeExpand = "io.snyk.eclipse.plugin.commands.TreeExpand";
18+
19+
if (commandId.equals(treeCollapse)) {
1820
SnykStartup.getView().getTreeViewer().collapseAll();
19-
break;
20-
case "io.snyk.eclipse.plugin.commands.TreeExpand":
21+
} else if (commandId.equals(treeExpand)) {
2122
SnykStartup.getView().getTreeViewer().expandAll();
22-
break;
2323
}
2424

2525
return null;
2626
}
27-
}
27+
}

plugin/src/main/java/io/snyk/languageserver/ScanState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package io.snyk.languageserver;
22

3+
import java.util.Map;
34
import java.util.concurrent.ConcurrentHashMap;
45

56
public class ScanState {
67
private ScanState() {
78

89
}
910

10-
private final ConcurrentHashMap<ScanInProgressKey, Boolean> scanInProgress = new ConcurrentHashMap<>();
11+
private final Map<ScanInProgressKey, Boolean> scanInProgress = new ConcurrentHashMap<>();
1112

1213
private static ScanState instance = new ScanState();
1314
public static ScanState getInstance() {

plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public void snykScan(SnykScanParam param) {
367367
for (ProductTreeNode productTreeNode : affectedProductTreeNodes) {
368368
this.toolView.resetNode(productTreeNode);
369369
addInfoNodes(productTreeNode, param.getFolderPath(), issueCache);
370-
populateFileAndIssueNodes(productTreeNode, param.getFolderPath(), issueCache);
370+
populateFileAndIssueNodes(productTreeNode, issueCache);
371371
}
372372
break;
373373
case SCAN_STATE_ERROR:
@@ -535,7 +535,7 @@ public void publishDiagnostics316(PublishDiagnostics316Param param) {
535535
populateIssueCache(param, filePath);
536536
}
537537

538-
private void populateFileAndIssueNodes(ProductTreeNode productTreeNode, String folderPath,
538+
private void populateFileAndIssueNodes(ProductTreeNode productTreeNode,
539539
SnykIssueCache issueCache) {
540540
var cacheHashMap = issueCache.getCacheByDisplayProduct(productTreeNode.getProduct());
541541
for (var kv : cacheHashMap.entrySet()) {

0 commit comments

Comments
 (0)