Skip to content

Commit ef3e428

Browse files
committed
fix(SP-2588): Intellij inspect cleanup
1 parent 0da24ab commit ef3e428

File tree

8 files changed

+18
-25
lines changed

8 files changed

+18
-25
lines changed

src/main/java/com/scanoss/Scanner.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.scanoss.utils.JsonUtils;
3636
import lombok.*;
3737
import lombok.extern.slf4j.Slf4j;
38+
import org.jetbrains.annotations.NotNull;
3839

3940
import java.io.File;
4041
import java.io.IOException;
@@ -223,17 +224,19 @@ public List<String> processFolder(@NonNull String folder, FileProcessor processo
223224
List<Future<String>> futures = new ArrayList<>();
224225
try {
225226
Files.walkFileTree(Paths.get(folder), new SimpleFileVisitor<>() {
227+
@NotNull
226228
@Override
227-
public FileVisitResult preVisitDirectory(Path file, BasicFileAttributes attrs) {
229+
public FileVisitResult preVisitDirectory(Path file, @NotNull BasicFileAttributes attrs) {
228230
if(folderFilter.test(file)) {
229231
log.debug("Processing file: {}", file.getFileName().toString());
230232
return FileVisitResult.SKIP_SUBTREE; // Skip the rest of this directory tree
231233
}
232234
return FileVisitResult.CONTINUE;
233235
}
234236

237+
@NotNull
235238
@Override
236-
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
239+
public FileVisitResult visitFile(Path file, @NotNull BasicFileAttributes attrs) {
237240
if (attrs.isRegularFile() && !fileFilter.test(file) && attrs.size() > 0) {
238241
String filename = file.toString();
239242
Future<String> future = executorService.submit(() -> processor.process(filename, stripDirectory(folder, filename)));
@@ -292,7 +295,7 @@ public List<String> processFileList(@NonNull String root, @NonNull List<String>
292295
if (skipDir) {
293296
continue; // skip this file as the folder is not allowed
294297
}
295-
String nameLower = path.getFileName().toString().toLowerCase();
298+
296299
if (!this.fileFilter.test(path)) {
297300
Path fullPath = Path.of(root, file);
298301
File f = fullPath.toFile();

src/main/java/com/scanoss/ScannerPostProcessor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ private void buildPurl2ComponentDetailsMap(@NonNull List<ScanFileResult> scanFil
146146
*
147147
* @param results The list of scan results to process and modify
148148
* @param rules The list of replacement rules to apply
149-
* @return The modified input list of scan results with updated PURLs
150149
*/
151150
private void applyReplaceRules(@NonNull List<ScanFileResult> results, @NonNull List<ReplaceRule> rules) {
152151
log.debug("Starting replace rules application for {} results with {} rules", results.size(), rules.size());
@@ -268,7 +267,7 @@ private ScanFileDetails createUpdatedResultDetails(ScanFileDetails existingCompo
268267

269268
/**
270269
* Marks all components in the list as non-matching by replacing each component
271-
* with a new instance that has MatchType.NONE while preserving the serverDetails
270+
* with a new instance that has MatchType. NONE while preserving the serverDetails
272271
* Modifies the input list in place using List.replaceAll().
273272
*
274273
* @param components List of scan file details to be marked as non-matching
@@ -451,7 +450,7 @@ private boolean isPurlMatch(String rulePurl, String[] resultPurls) {
451450
* 1. The result has a valid file path identifier
452451
* 2. The result contains a non-empty list of scan details
453452
* 3. The primary scan detail entry (first in the list) exists
454-
*
453+
* <p>
455454
* This structural validation is a prerequisite for any further processing of scan results,
456455
* such as match analysis or rule processing. Without these basic elements, the scan result
457456
* cannot be meaningfully processed.

src/main/java/com/scanoss/cli/ScanCommandLine.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ public void run() {
121121
throw new RuntimeException("Error: No file or folder specified to scan");
122122
}
123123

124-
//TODO: Deprecate options
125-
String sbomType = null;
126-
String sbom = null;
127-
128124
String caCertPem = null;
129125
if (caCert != null && !caCert.isEmpty()) {
130126
caCertPem = loadFileToString(caCert);
@@ -167,7 +163,7 @@ public void run() {
167163
scanner = Scanner.builder().skipSnippets(skipSnippets).allFolders(allFolders).allExtensions(allExtensions)
168164
.hiddenFilesFolders(allHidden).numThreads(numThreads).url(apiUrl).apiKey(apiKey)
169165
.retryLimit(retryLimit).timeout(Duration.ofSeconds(timeoutLimit)).scanFlags(scanFlags)
170-
.sbomType(sbomType).sbom(sbom).snippetLimit(snippetLimit).customCert(caCertPem).proxy(proxy).hpsm(enableHpsm)
166+
.snippetLimit(snippetLimit).customCert(caCertPem).proxy(proxy).hpsm(enableHpsm)
171167
.settings(settings).obfuscate(obfuscate)
172168
.build();
173169

src/main/java/com/scanoss/rest/HttpStatusCode.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
package com.scanoss.rest;
2424

25+
import lombok.Getter;
26+
2527
/**
2628
* Enum list of standard HTTP Status Codes
2729
*/
@@ -281,6 +283,10 @@ public enum HttpStatusCode {
281283
*/
282284
NETWORK_AUTHENTICATION_REQUIRED(511, "Network Authentication Required");
283285

286+
/**
287+
* Get the Integer value of the HTTP Status Code
288+
*/
289+
@Getter
284290
private final int value;
285291
private final String description;
286292

@@ -310,15 +316,6 @@ public static String getByValueToString(int value) {
310316
return value + " Unknown Status Code";
311317
}
312318

313-
/**
314-
* Get the Integer value of the HTTP Status Code
315-
*
316-
* @return HTTP status integer value
317-
*/
318-
public int getValue() {
319-
return value;
320-
}
321-
322319
/**
323320
* String friendly version of the HTTP Status Code
324321
*

src/main/java/com/scanoss/utils/Hpsm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class Hpsm {
3939
private static final int CRC8_MAXIM_DOW_POLYNOMIAL = 0x8C; // 0x31 reflected
4040
private static final int CRC8_MAXIM_DOW_INITIAL = 0x00; // 0x00 reflected
4141
private static final int CRC8_MAXIM_DOW_FINAL = 0x00; // 0x00 reflected
42-
private static int[] crc8MaximDowTable = new int[CRC8_MAXIM_DOW_TABLE_SIZE];
42+
private static final int[] crc8MaximDowTable = new int[CRC8_MAXIM_DOW_TABLE_SIZE];
4343

4444
private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII);
4545

src/test/java/com/scanoss/TestBom.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ public void testReplaceRulesSortingWithDuplicatePaths() {
110110

111111
// Verify the rules with same path length maintain original order
112112
assertEquals("Size should be 2", 2, sortedRules.size());
113-
assertTrue("Both rules should have same priority",
114-
new RuleComparator().compare(sortedRules.get(0), sortedRules.get(1)) == 0);
113+
assertEquals("Both rules should have same priority", 0, new RuleComparator().compare(sortedRules.get(0), sortedRules.get(1)));
115114

116115
log.info("Finished testReplaceRulesSortingWithDuplicatePaths -->");
117116
}

src/test/java/com/scanoss/TestScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public void TestScannerFiltering() {
341341
f = "testing/data/folder-ends-with-nbproject";
342342
Scanner scanner = Scanner.builder().build();
343343
List<String> wfps = scanner.wfpFolder(f);
344-
assertTrue("WFP should NOT be empty", !wfps.isEmpty());
344+
assertFalse("WFP should NOT be empty", wfps.isEmpty());
345345

346346
log.info("Testing filtering: file nbproject should not be filtered... ");
347347
f = "testing/data";

src/test/java/com/scanoss/TestSettings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.nio.file.Files;
3333
import java.nio.file.Path;
3434
import java.nio.file.Paths;
35-
import java.util.ArrayList;
3635
import java.util.List;
3736

3837
import static org.junit.Assert.*;

0 commit comments

Comments
 (0)