Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Sync source code with external modules #420

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
</parent>

<properties>
Expand Down Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
<version>1.16.0</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand Down Expand Up @@ -159,14 +159,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.10.0</version>
<configuration>
<release>17</release>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArgs>
<arg>-Xlint:all,-serial,-processing</arg>
</compilerArgs>
<excludes>
<exclude>**/package-info.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/entity/LPVSDetectedLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* This class is mapped to the "detected_license" table in the "lpvs" schema.
*/
@Entity
@Table(name = "detected_license", schema = "lpvs")
@Table(name = "detected_license", schema = "${lpvs.schema:lpvs}")
@Getter
@Setter
public class LPVSDetectedLicense implements Serializable {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/entity/LPVSLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Entity
@Table(
name = "licenses",
schema = "lpvs",
schema = "${lpvs.schema:lpvs}",
indexes = {@Index(name = "spdx_id", columnList = "license_spdx", unique = true)})
@Getter
@Setter
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/entity/LPVSLicenseConflict.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* This class is mapped to the "license_conflicts" table in the "lpvs" schema.
*/
@Entity
@Table(name = "license_conflicts", schema = "lpvs")
@Table(name = "license_conflicts", schema = "${lpvs.schema:lpvs}")
@Getter
@Setter
@NoArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/entity/LPVSPullRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* This class is mapped to the "pull_requests" table in the "lpvs" schema.
*/
@Entity
@Table(name = "pull_requests", schema = "lpvs")
@Table(name = "pull_requests", schema = "${lpvs.schema:lpvs}")
@Getter
@Setter
@AllArgsConstructor
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/entity/LPVSQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* This class is mapped to the "queue" table in the "lpvs" schema.
*/
@Entity
@Table(name = "queue", schema = "lpvs")
@Table(name = "queue", schema = "${lpvs.schema:lpvs}")
@Getter
@Setter
public class LPVSQueue implements Serializable {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/entity/auth/LPVSMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@Entity
@Table(
name = "member",
schema = "lpvs",
schema = "${lpvs.schema:lpvs}",
indexes = {@Index(name = "unq_member", columnList = "email, provider", unique = true)})
public class LPVSMember {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public enum LPVSPullRequestAction {
/**
* Represents the action of triggering a manual single scan of a pull request.
*/
SINGLE_SCAN("single-scan");
SINGLE_SCAN("single-scan"),

/**
* Represents the action of triggering a scan of a pull request by automation bot.
*/
BOT_SCAN("bot-scan");

/**
* The string representation of the pull request action.
Expand Down Expand Up @@ -84,6 +89,8 @@ public static LPVSPullRequestAction convertFrom(String action) {
return RESCAN;
} else if (action.equals(SINGLE_SCAN.getPullRequestAction())) {
return SINGLE_SCAN;
} else if (action.equals(BOT_SCAN.getPullRequestAction())) {
return BOT_SCAN;
} else {
return null;
}
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/lpvs/service/LPVSGitHubService.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,10 @@ public void commentResults(
}
commitCommentBuilder.append("</ul>");
if (null != webhookConfig.getHubLink()) {
commitCommentBuilder.append("(");
commitCommentBuilder.append(
"\n\n###### <p align='right'>Check the validation details at the link(");
commitCommentBuilder.append(webhookConfig.getHubLink());
commitCommentBuilder.append(")");
commitCommentBuilder.append(")</p>");
}
commitComment += commitCommentBuilder.toString();
}
Expand All @@ -345,8 +346,7 @@ public void commentResults(
pullRequestRepository.save(lpvsPullRequest);
pullRequest.comment(
"**\\[License Pre-Validation Service\\]** Potential license problem(s) detected \n\n"
+ commitComment
+ "</p>");
+ commitComment);
repository.createCommitStatus(
webhookConfig.getHeadCommitSHA(),
GHCommitState.FAILURE,
Expand All @@ -358,8 +358,7 @@ public void commentResults(
pullRequestRepository.save(lpvsPullRequest);
pullRequest.comment(
"**\\[License Pre-Validation Service\\]** No license issue detected \n\n"
+ commitComment
+ "</p>");
+ commitComment);
repository.createCommitStatus(
webhookConfig.getHeadCommitSHA(),
GHCommitState.SUCCESS,
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/lpvs/util/LPVSFileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public class LPVSFileUtil {
*/
public static void saveFile(String fileName, String directoryPath, List<String> patchedLines) {
try {
if (patchedLines == null || patchedLines.size() == 0) {
log.error("Empty patch for file " + fileName);
return;
}
int cnt = 1;
StringBuilder prettyPatch = new StringBuilder();
for (String patchedLine : patchedLines) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ lpvs.cores=8
lpvs.attempts=4

# DB Configuration
# The name of DB schema
lpvs.schema=lpvs
tiokim marked this conversation as resolved.
Show resolved Hide resolved

spring.jpa.open-in-view=true
spring.jpa.properties.hibernate.connection.CharSet=utf8
spring.jpa.properties.hibernate.connection.characterEncoding=utf8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void testConvertFrom() {
assertEquals(
LPVSPullRequestAction.convertFrom("single-scan"),
LPVSPullRequestAction.SINGLE_SCAN);
assertEquals(LPVSPullRequestAction.convertFrom("bot-scan"), LPVSPullRequestAction.BOT_SCAN);

assertNotEquals(
LPVSPullRequestAction.convertFrom("random_name"), LPVSPullRequestAction.OPEN);
Expand All @@ -37,6 +38,8 @@ public void testConvertFrom() {
assertNotEquals(
LPVSPullRequestAction.convertFrom("random_name"),
LPVSPullRequestAction.SINGLE_SCAN);
assertNotEquals(
LPVSPullRequestAction.convertFrom("random_name"), LPVSPullRequestAction.BOT_SCAN);

assertNull(LPVSPullRequestAction.convertFrom("random_name"));
}
Expand All @@ -49,5 +52,6 @@ public void testGetPullRequestAction() {
assertEquals(LPVSPullRequestAction.UPDATE.getPullRequestAction(), "synchronize");
assertEquals(LPVSPullRequestAction.RESCAN.getPullRequestAction(), "rescan");
assertEquals(LPVSPullRequestAction.SINGLE_SCAN.getPullRequestAction(), "single-scan");
assertEquals(LPVSPullRequestAction.BOT_SCAN.getPullRequestAction(), "bot-scan");
}
}
43 changes: 23 additions & 20 deletions src/test/java/com/lpvs/service/LPVSGitHubServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,8 @@ class TestCommentResults__ProhibitedPresentConflictsPresent {
+ " * found in the LICENSE file.\n"
+ " */\n\n\n\n\n"
+ "**Detected license conflicts:**\n\n\n"
+ "<ul><li>MIT and Apache-1.0</li></ul>()</p>";
+ "<ul><li>MIT and Apache-1.0</li></ul>"
+ "\n\n###### <p align='right'>Check the validation details at the link()</p>";

@BeforeEach
void setUp() {
Expand Down Expand Up @@ -2508,7 +2509,8 @@ class TestCommentResults__EmptyPresentConflictsPresent {
+ " * found in the LICENSE file.\n"
+ " */\n\n\n\n\n"
+ "**Detected license conflicts:**\n\n\n"
+ "<ul><li>MIT and Apache-1.0</li></ul>()</p>";
+ "<ul><li>MIT and Apache-1.0</li></ul>"
+ "\n\n###### <p align='right'>Check the validation details at the link()</p>";

@BeforeEach
void setUp() {
Expand Down Expand Up @@ -2661,7 +2663,7 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresent()
+ LPVSWebhookUtil.getRepositoryName(webhookConfig));
} catch (IOException e) {
log.error(
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresent() error "
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresent() error "
+ e);
fail();
}
Expand All @@ -2679,7 +2681,7 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresent()
"[License Pre-Validation Service]");
} catch (IOException e) {
log.error(
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresent() error "
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresent() error "
+ e);
fail();
}
Expand Down Expand Up @@ -2721,7 +2723,7 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt()
+ LPVSWebhookUtil.getRepositoryName(webhookConfig));
} catch (IOException e) {
log.error(
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresent() error "
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt() error "
+ e);
fail();
}
Expand All @@ -2739,7 +2741,7 @@ public void testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt()
"[License Pre-Validation Service]");
} catch (IOException e) {
log.error(
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresent() error "
"TestCommentResults__EmptyPresentConflictsPresent.testCommentResults__EmptyPresentConflictsPresentLicensePresentAlt() error "
+ e);
fail();
}
Expand Down Expand Up @@ -2835,7 +2837,8 @@ class TestCommentResults__UnreviewedPresentConflictsPresent {
+ " * found in the LICENSE file.\n"
+ " */\n\n\n\n\n"
+ "**Detected license conflicts:**\n\n\n"
+ "<ul><li>MIT and Apache-1.0</li></ul>()</p>";
+ "<ul><li>MIT and Apache-1.0</li></ul>"
+ "\n\n###### <p align='right'>Check the validation details at the link()</p>";

@BeforeEach
void setUp() {
Expand Down Expand Up @@ -2931,7 +2934,7 @@ public void testCommentResults__RestrictedPresentConflictsPresent() throws IOExc
+ LPVSWebhookUtil.getRepositoryName(webhookConfig));
} catch (IOException e) {
log.error(
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__UnreviewedPresentConflictsPresent() error "
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error "
+ e);
fail();
}
Expand All @@ -2949,7 +2952,7 @@ public void testCommentResults__RestrictedPresentConflictsPresent() throws IOExc
"[License Pre-Validation Service]");
} catch (IOException e) {
log.error(
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__UnreviewedPresentConflictsPresent() error "
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error "
+ e);
fail();
}
Expand Down Expand Up @@ -2990,7 +2993,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent(
+ LPVSWebhookUtil.getRepositoryName(webhookConfig));
} catch (IOException e) {
log.error(
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__UnreviewedPresentConflictsPresent() error "
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error "
+ e);
fail();
}
Expand All @@ -3008,7 +3011,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent(
"[License Pre-Validation Service]");
} catch (IOException e) {
log.error(
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__UnreviewedPresentConflictsPresent() error "
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error "
+ e);
fail();
}
Expand Down Expand Up @@ -3050,7 +3053,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA
+ LPVSWebhookUtil.getRepositoryName(webhookConfig));
} catch (IOException e) {
log.error(
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__UnreviewedPresentConflictsPresent() error "
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error "
+ e);
fail();
}
Expand All @@ -3068,7 +3071,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA
"[License Pre-Validation Service]");
} catch (IOException e) {
log.error(
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__UnreviewedPresentConflictsPresent() error "
"TestCommentResults__UnreviewedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error "
+ e);
fail();
}
Expand Down Expand Up @@ -3164,7 +3167,8 @@ class TestCommentResults__RestrictedPresentConflictsPresent {
+ " * found in the LICENSE file.\n"
+ " */\n\n\n\n\n"
+ "**Detected license conflicts:**\n\n\n"
+ "<ul><li>MIT and Apache-1.0</li></ul>()</p>";
+ "<ul><li>MIT and Apache-1.0</li></ul>"
+ "\n\n###### <p align='right'>Check the validation details at the link()</p>";

@BeforeEach
void setUp() {
Expand Down Expand Up @@ -3319,7 +3323,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent(
+ LPVSWebhookUtil.getRepositoryName(webhookConfig));
} catch (IOException e) {
log.error(
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error "
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error "
+ e);
fail();
}
Expand All @@ -3337,7 +3341,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresent(
"[License Pre-Validation Service]");
} catch (IOException e) {
log.error(
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error "
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresent() error "
+ e);
fail();
}
Expand Down Expand Up @@ -3379,7 +3383,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA
+ LPVSWebhookUtil.getRepositoryName(webhookConfig));
} catch (IOException e) {
log.error(
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error "
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error "
+ e);
fail();
}
Expand All @@ -3397,7 +3401,7 @@ public void testCommentResults__RestrictedPresentConflictsPresentLicensePresentA
"[License Pre-Validation Service]");
} catch (IOException e) {
log.error(
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresent() error "
"TestCommentResults__RestrictedPresentConflictsPresent.testCommentResults__RestrictedPresentConflictsPresentLicensePresentAlt() error "
+ e);
fail();
}
Expand Down Expand Up @@ -3476,8 +3480,7 @@ class TestCommentResults__ProhibitedAbsentConflictsAbsent {
+ " *\n"
+ " * Use of this source code is governed by a MIT license that can be\n"
+ " * found in the LICENSE file.\n"
+ " */\n\n\n\n\n"
+ "</p>";
+ " */\n\n\n\n\n";

@BeforeEach
void setUp() {
Expand Down
Loading
Loading