Skip to content

Commit 89392dd

Browse files
committed
fix(SP-2588): Intellij inspect cleanup
1 parent 0ec8201 commit 89392dd

File tree

8 files changed

+19
-26
lines changed

8 files changed

+19
-26
lines changed

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

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

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

235+
@NotNull
233236
@Override
234-
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
237+
public FileVisitResult visitFile(Path file, @NotNull BasicFileAttributes attrs) {
235238
if (attrs.isRegularFile() && !fileFilter.test(file) && attrs.size() > 0) {
236239
String filename = file.toString();
237240
Future<String> future = executorService.submit(() -> processor.process(filename, stripDirectory(folder, filename)));
@@ -290,7 +293,7 @@ public List<String> processFileList(@NonNull String root, @NonNull List<String>
290293
if (skipDir) {
291294
continue; // skip this file as the folder is not allowed
292295
}
293-
String nameLower = path.getFileName().toString().toLowerCase();
296+
294297
if (!this.fileFilter.test(path)) {
295298
Path fullPath = Path.of(root, file);
296299
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: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ public void run() {
118118
throw new RuntimeException("Error: No file or folder specified to scan");
119119
}
120120

121-
//TODO: Deprecate options
122-
String sbomType = null;
123-
String sbom = null;
124-
125121
String caCertPem = null;
126122
if (caCert != null && !caCert.isEmpty()) {
127123
caCertPem = loadFileToString(caCert);
@@ -164,7 +160,7 @@ public void run() {
164160
scanner = Scanner.builder().skipSnippets(skipSnippets).allFolders(allFolders).allExtensions(allExtensions)
165161
.hiddenFilesFolders(allHidden).numThreads(numThreads).url(apiUrl).apiKey(apiKey)
166162
.retryLimit(retryLimit).timeout(Duration.ofSeconds(timeoutLimit)).scanFlags(scanFlags)
167-
.sbomType(sbomType).sbom(sbom).snippetLimit(snippetLimit).customCert(caCertPem).proxy(proxy).hpsm(enableHpsm)
163+
.snippetLimit(snippetLimit).customCert(caCertPem).proxy(proxy).hpsm(enableHpsm)
168164
.settings(settings)
169165
.build();
170166

@@ -241,7 +237,7 @@ private void scanFolder(String folder) {
241237
JsonUtils.writeJsonPretty(JsonUtils.joinJsonObjects(JsonUtils.toJsonObjects(results)), out);
242238
return;
243239
}
244-
printMsg(err, String.format("Found 0 results."));
240+
printMsg(err, "Found 0 results.");
245241
} catch (ScannerException | WinnowingException e) {
246242
if (CommandLine.debug) {
247243
e.printStackTrace(err);

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
@@ -283,7 +283,7 @@ public void TestScannerFiltering() {
283283
f = "testing/data/folder-ends-with-nbproject";
284284
Scanner scanner = Scanner.builder().build();
285285
List<String> wfps = scanner.wfpFolder(f);
286-
assertTrue("WFP should NOT be empty", !wfps.isEmpty());
286+
assertFalse("WFP should NOT be empty", wfps.isEmpty());
287287

288288
log.info("Testing filtering: file nbproject should not be filtered... ");
289289
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)