Skip to content

Commit

Permalink
fix: updated comment messages after code review
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
  • Loading branch information
o-kopysov committed Aug 28, 2024
1 parent e8f0d93 commit 5a14523
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 60 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ public String generateCommandLineComment(
long licenseDetected = prohibitedLicenses + restrictedLicenses + unreviewedLicenses;

if (licenseDetected > 0) {
commentBuilder.append(
"Potential license problem(s) detected: " + licenseDetected + "\n");
commentBuilder.append("Potential license issues detected: " + licenseDetected + "\n");
if (prohibitedLicenses > 0) {
commentBuilder.append(" - Prohibited license(s): " + prohibitedLicenses + "\n");
}
Expand Down Expand Up @@ -274,7 +273,7 @@ public String generatePullRequestComment(
long licenseDetected = prohibitedLicenses + restrictedLicenses + unreviewedLicenses;

if (licenseDetected > 0) {
commitCommentBuilder.append("Potential license problem(s) detected:\n");
commitCommentBuilder.append("Potential license issues detected:\n");
if (prohibitedLicenses > 0) {
commitCommentBuilder.append(
" - Prohibited license(s): " + prohibitedLicenses + "\n");
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/lpvs/service/LPVSGitHubService.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void setPendingCheck(LPVSQueue webhookConfig) {
GHCommitState.PENDING,
null,
"Scanning opensource licenses",
"[License Pre-Validation Service]");
"[LPVS]");
} catch (IOException | IllegalArgumentException e) {
log.error("Can't authorize setPendingCheck(): " + e.getMessage());
}
Expand All @@ -200,7 +200,7 @@ public void setErrorCheck(LPVSQueue webhookConfig) {
GHCommitState.ERROR,
null,
"Scanning process failed",
"[License Pre-Validation Service]");
"[LPVS]");
} catch (IOException | IllegalArgumentException e) {
log.error("Can't authorize setErrorCheck(): " + e.getMessage());
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public void commentResults(
GHCommitState.SUCCESS,
null,
"Files are not found",
"[License Pre-Validation Service]");
"[LPVS]");
return;
}

Expand Down Expand Up @@ -320,26 +320,23 @@ public void commentResults(
lpvsPullRequest.setStatus(LPVSPullRequestStatus.ISSUES_DETECTED.toString());
pullRequestRepository.save(lpvsPullRequest);
pullRequest.comment(
"**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n"
+ commitComment);
"**\\[LPVS\\]** Potential license issues detected \n\n" + commitComment);
repository.createCommitStatus(
webhookConfig.getHeadCommitSHA(),
GHCommitState.FAILURE,
null,
"Potential license problem(s) detected",
"[License Pre-Validation Service]");
"Potential license issues detected",
"[LPVS]");
} else {
lpvsPullRequest.setStatus(LPVSPullRequestStatus.COMPLETED.toString());
pullRequestRepository.save(lpvsPullRequest);
pullRequest.comment(
"**\\[License Pre-Validation Service\\]** No license issue detected \n\n"
+ commitComment);
pullRequest.comment("**\\[LPVS\\]** No license issue detected \n\n" + commitComment);
repository.createCommitStatus(
webhookConfig.getHeadCommitSHA(),
GHCommitState.SUCCESS,
null,
"No license issue(s) detected",
"[License Pre-Validation Service]");
"No license issues detected",
"[LPVS]");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/report_single_scan.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1><b>Report</b> - <b>L</b>icense <b>P</b>re-<b>V</b>alidation <b>S</b>ervice (
<hr>
<h3 class="ml-30">Detected Licenses</h3>
<div class="items" th:if="${licenseDetected} > 0">
<b>Potential license problem(s) detected:</b> <span th:text=${licenseDetected}>licenseDetected</span>
<b>Potential license issues detected:</b> <span th:text=${licenseDetected}>licenseDetected</span>
<ul>
<li th:if="${prohibitedLicenses} > 0">Prohibited license(s): <span th:text=${prohibitedLicenses}>prohibitedLicenses</span></li>
<li th:if="${restrictedLicenses} > 0">Restricted license(s): <span th:text=${restrictedLicenses}>restrictedLicenses</span></li>
Expand Down
Loading

0 comments on commit 5a14523

Please sign in to comment.