Skip to content

Commit

Permalink
refactor: Use LPVSFileUtil API for getReader
Browse files Browse the repository at this point in the history
Signed-off-by: Taewan Kim <t25.kim@samsung.com>
  • Loading branch information
tiokim committed Jun 4, 2024
1 parent 3005e51 commit 50bbb32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.lpvs.repository.LPVSLicenseRepository;
import com.lpvs.service.LPVSLicenseService;
import com.lpvs.service.scan.LPVSScanService;
import com.lpvs.util.LPVSFileUtil;
import com.lpvs.util.LPVSPayloadUtil;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -244,24 +245,9 @@ private ScanossJsonStructure getScanossJsonStructure(String content, LPVSFile fi
* @throws IOException If an error occurs while creating the BufferedReader object.
*/
private static Reader getReader(LPVSQueue webhookConfig) throws IOException {
String fileName = null;
if (webhookConfig.getHeadCommitSHA() == null
|| webhookConfig.getHeadCommitSHA().isBlank()) {
fileName = LPVSPayloadUtil.getPullRequestId(webhookConfig);
} else {
fileName = webhookConfig.getHeadCommitSHA();
}

return Files.newBufferedReader(
Paths.get(
System.getProperty("user.home")
+ File.separator
+ "Results"
+ File.separator
+ LPVSPayloadUtil.getRepositoryName(webhookConfig)
+ File.separator
+ fileName
+ ".json"));
LPVSFileUtil.getScanResultsJsonFilePath(webhookConfig)));
}

/**
Expand Down
30 changes: 13 additions & 17 deletions src/main/java/com/lpvs/util/LPVSFileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,22 @@ public static String getLocalDirectoryPath(LPVSQueue webhookConfig) {
* @return The file path for storing scan results in JSON format.
*/
public static String getScanResultsJsonFilePath(LPVSQueue webhookConfig) {
String fileName = null;
if (webhookConfig.getHeadCommitSHA() == null
|| webhookConfig.getHeadCommitSHA().equals("")) {
return System.getProperty("user.home")
+ File.separator
+ "Results"
+ File.separator
+ LPVSPayloadUtil.getRepositoryName(webhookConfig)
+ File.separator
+ LPVSPayloadUtil.getPullRequestId(webhookConfig)
+ ".json";
|| webhookConfig.getHeadCommitSHA().isBlank()) {
fileName = LPVSPayloadUtil.getPullRequestId(webhookConfig);
} else {
return System.getProperty("user.home")
+ File.separator
+ "Results"
+ File.separator
+ LPVSPayloadUtil.getRepositoryName(webhookConfig)
+ File.separator
+ webhookConfig.getHeadCommitSHA()
+ ".json";
fileName = webhookConfig.getHeadCommitSHA();
}

return System.getProperty("user.home")
+ File.separator
+ "Results"
+ File.separator
+ LPVSPayloadUtil.getRepositoryName(webhookConfig)
+ File.separator
+ fileName
+ ".json";
}

/**
Expand Down

0 comments on commit 50bbb32

Please sign in to comment.