Skip to content

Commit dd93824

Browse files
committed
fix: more linter warnings
1 parent 5b278e8 commit dd93824

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

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/ProductTreeNode.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ProductTreeNode extends BaseTreeNode {
1818

1919
public ProductTreeNode(String value) {
2020
super(value);
21-
this.setProduct(value);
21+
initializeProduct(product);
2222

2323
switch (value) {
2424
case ProductConstants.DISPLAYED_OSS:
@@ -37,6 +37,13 @@ public ProductTreeNode(String value) {
3737
setImageDescriptor(SnykIcons.CODE);
3838
prefEnablementKey = Preferences.ACTIVATE_SNYK_CODE_SECURITY;
3939
break;
40+
default:
41+
// Handle unexpected values
42+
setImageDescriptor(null);
43+
prefEnablementKey = "";
44+
// Optionally, log an error or throw an exception
45+
System.err.println("Unexpected product value: " + value);
46+
break;
4047
}
4148

4249

@@ -134,7 +141,7 @@ public String getProduct() {
134141
}
135142

136143
public void setProduct(String product) {
137-
this.product = product;
144+
initializeProduct(product);
138145
}
139146

140147
public String getErrorMessage() {
@@ -144,4 +151,10 @@ public String getErrorMessage() {
144151
public void setErrorMessage(String errorMessage) {
145152
this.errorMessage = errorMessage;
146153
}
154+
155+
private void initializeProduct(String product) {
156+
this.setProduct(product);
157+
}
158+
159+
147160
}

0 commit comments

Comments
 (0)