From 5a145239e2566269bf1e16836463997e1d9a672b Mon Sep 17 00:00:00 2001 From: Oleg Kopysov Date: Wed, 28 Aug 2024 09:42:09 +0300 Subject: [PATCH] fix: updated comment messages after code review Signed-off-by: Oleg Kopysov --- .../lpvs/entity/report/LPVSReportBuilder.java | 5 +- .../com/lpvs/service/LPVSGitHubService.java | 21 ++--- .../templates/report_single_scan.html | 2 +- .../lpvs/service/LPVSGitHubServiceTest.java | 88 +++++++++---------- 4 files changed, 56 insertions(+), 60 deletions(-) diff --git a/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java b/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java index e1b22299..468abd58 100644 --- a/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java +++ b/src/main/java/com/lpvs/entity/report/LPVSReportBuilder.java @@ -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"); } @@ -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"); diff --git a/src/main/java/com/lpvs/service/LPVSGitHubService.java b/src/main/java/com/lpvs/service/LPVSGitHubService.java index 81f08cd5..6422f590 100644 --- a/src/main/java/com/lpvs/service/LPVSGitHubService.java +++ b/src/main/java/com/lpvs/service/LPVSGitHubService.java @@ -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()); } @@ -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()); } @@ -243,7 +243,7 @@ public void commentResults( GHCommitState.SUCCESS, null, "Files are not found", - "[License Pre-Validation Service]"); + "[LPVS]"); return; } @@ -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]"); } } diff --git a/src/main/resources/templates/report_single_scan.html b/src/main/resources/templates/report_single_scan.html index 64860931..b58e3f3b 100644 --- a/src/main/resources/templates/report_single_scan.html +++ b/src/main/resources/templates/report_single_scan.html @@ -90,7 +90,7 @@

Report - License Pre-Validation Service (

Detected Licenses

- Potential license problem(s) detected: licenseDetected + Potential license issues detected: licenseDetected
  • Prohibited license(s): prohibitedLicenses
  • Restricted license(s): restrictedLicenses
  • diff --git a/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java b/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java index 589867a2..968b23ae 100644 --- a/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java +++ b/src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java @@ -1218,7 +1218,7 @@ void setUp() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1264,7 +1264,7 @@ public void testSetPendingCheck__ApiUrlAbsentNormalExecution() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetPendingCheck__ApiUrlAbsentNormalExecution.testSetPendingCheck__ApiUrlAbsentNormalExecution() error " @@ -1326,7 +1326,7 @@ void setUp() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1379,7 +1379,7 @@ public void testSetPendingCheck__ApiUrlPresentNormalExecution() { GHCommitState.PENDING, null, "Scanning opensource licenses", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetPendingCheck__ApiUrlPresentNormalExecution.testSetPendingCheck__ApiUrlPresentNormalExecution() error " @@ -1542,7 +1542,7 @@ void setUp() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1588,7 +1588,7 @@ public void testSetErrorCheck__ApiUrlAbsentNormalExecution() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetErrorCheck__ApiUrlAbsentNormalExecution.testSetErrorCheck__ApiUrlAbsentNormalExecution() error " @@ -1650,7 +1650,7 @@ void setUp() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]")) + "[LPVS]")) .thenReturn(null); } catch (IOException e) { log.error("mocked_repo.getPullRequests error " + e); @@ -1703,7 +1703,7 @@ public void testSetErrorCheck__ApiUrlPresentNormalExecution() { GHCommitState.ERROR, null, "Scanning process failed", - "[License Pre-Validation Service]"); + "[LPVS]"); } catch (IOException e) { log.error( "TestSetErrorCheck__ApiUrlPresentNormalExecution.testSetErrorCheck__ApiUrlPresentNormalExecution() error " @@ -2086,8 +2086,8 @@ public void testCommentResults__ScanResultsEmpty() throws Exception { commit_sha, GHCommitState.SUCCESS, null, - "No license issue(s) detected", - "[License Pre-Validation Service]"); + "No license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ScanResultsEmpty.testCommentResults__ScanResultsEmpty() error " @@ -2163,10 +2163,10 @@ class TestCommentResults__ProhibitedPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" + "**\\[LPVS\\]** Potential license issues detected \n\n" + "**Detected Licenses:**\n" + "\n" - + "Potential license problem(s) detected:\n" + + "Potential license issues detected:\n" + " - Prohibited license(s): 1\n" + "\n" + "
    \n" @@ -2295,8 +2295,8 @@ public void testCommentResults__ProhibitedPresentConflictsPresent() throws Excep commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ProhibitedPresentConflictsPresent.testCommentResults__ProhibitedPresentConflictsPresent() error " @@ -2354,8 +2354,8 @@ public void testCommentResults__ProhibitedPresentConflictsPresentLicensePresent( commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ProhibitedPresentConflictsPresent.testCommentResults__ProhibitedPresentConflictsPresentLicensePresent() error " @@ -2415,8 +2415,8 @@ public void testCommentResults__ProhibitedPresentConflictsPresentLicensePresentA commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__ProhibitedPresentConflictsPresent.testCommentResults__ProhibitedPresentConflictsPresentLicensePresentAlt() error " @@ -2497,7 +2497,7 @@ class TestCommentResults__EmptyPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" + "**\\[LPVS\\]** Potential license issues detected \n\n" + "**Detected Licenses:**\n" + "\n" + "No license problems detected.\n" @@ -2626,8 +2626,8 @@ public void testCommentResults__EmptyPresentConflictsPresent() throws Exception commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresent() error " @@ -2685,8 +2685,8 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresent() commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresent() error " @@ -2746,8 +2746,8 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt() commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (IOException e) { log.error( "TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt() error " @@ -2828,10 +2828,10 @@ class TestCommentResults__UnreviewedPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" + "**\\[LPVS\\]** Potential license issues detected \n\n" + "**Detected Licenses:**\n" + "\n" - + "Potential license problem(s) detected:\n" + + "Potential license issues detected:\n" + " - Unreviewed license(s): 1\n" + "\n" + "
    \n" @@ -2960,8 +2960,8 @@ public void testCommentResults__RestrictedPresentConflictsPresent() throws Excep commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error " @@ -3019,8 +3019,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent( commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error " @@ -3080,8 +3080,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error " @@ -3162,10 +3162,10 @@ class TestCommentResults__RestrictedPresentConflictsPresent { final String conflict_1_l2 = "Apache-1.0"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n" + "**\\[LPVS\\]** Potential license issues detected \n\n" + "**Detected Licenses:**\n" + "\n" - + "Potential license problem(s) detected:\n" + + "Potential license issues detected:\n" + " - Restricted license(s): 1\n" + "\n" + "
    \n" @@ -3294,8 +3294,8 @@ public void testCommentResults__RestrictedPresentConflictsPresent() throws Excep commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error " @@ -3353,8 +3353,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent( commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error " @@ -3414,8 +3414,8 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA commit_sha, GHCommitState.FAILURE, null, - "Potential license problem(s) detected", - "[License Pre-Validation Service]"); + "Potential license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error " @@ -3481,7 +3481,7 @@ class TestCommentResults__ProhibitedAbsentConflictsAbsent { final String checklist_url_1 = "https://opensource.org/licenses/MIT"; final String expected_comment = - "**\\[License Pre-Validation Service\\]** No license issue detected \n\n" + "**\\[LPVS\\]** No license issue detected \n\n" + "**Detected Licenses:**\n" + "\n" + "No license problems detected.\n" @@ -3596,8 +3596,8 @@ public void testCommentResults__ProhibitedAbsentConflictsAbsent() throws Excepti commit_sha, GHCommitState.SUCCESS, null, - "No license issue(s) detected", - "[License Pre-Validation Service]"); + "No license issues detected", + "[LPVS]"); } catch (Exception e) { log.error( "TestCommentResults__ProhibitedAbsentConflictsAbsent.testCommentResults__ProhibitedAbsentConflictsAbsent() error "