diff --git a/releasenotes-builder/config/checkstyle.properties b/releasenotes-builder/config/checkstyle.properties index 4b1a8c040..d728a8bdc 100644 --- a/releasenotes-builder/config/checkstyle.properties +++ b/releasenotes-builder/config/checkstyle.properties @@ -1,6 +1,6 @@ -checkstyle.suppressions.file=config/suppressions.xml checkstyle.header.file=https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java.header -checkstyle.regexp.header.file=https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java_regexp.header checkstyle.importcontrol.file=config/import-control.xml checkstyle.importcontroltest.file=config/import-control-test.xml +checkstyle.suppressions.file=config/suppressions.xml checkstyle.suppressions-xpath.file=https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/suppressions-xpath.xml +checkstyle.regexp.header.file=https://raw.githubusercontent.com/checkstyle/checkstyle/master/config/java_regexp.header diff --git a/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java b/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java index 394b0d590..76312ffa1 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/Main.java @@ -47,6 +47,7 @@ private Main() { * Entry point. * * @param args command line arguments. + * @noinspection UseOfSystemOutOrSystemErr, CallToSystemExit */ public static void main(String... args) { int errorCounter; @@ -63,7 +64,8 @@ public static void main(String... args) { final Result notesBuilderResult = runGithubNotesBuilder(cliOptions); errorCounter = notesBuilderResult.getErrorMessages().size(); if (errorCounter == 0) { - publicationErrors = MainProcess.run(notesBuilderResult.getReleaseNotes(), + publicationErrors = MainProcess.runMainProcess( + notesBuilderResult.getReleaseNotes(), cliOptions); } } @@ -122,6 +124,7 @@ private static Result runGithubNotesBuilder(CliOptions cliOptions) * Prints a list of elements in standard out. * * @param entities a list. + * @noinspection UseOfSystemOutOrSystemErr */ private static void printListOf(List entities) { System.out.println(); diff --git a/releasenotes-builder/src/main/java/com/github/checkstyle/MainProcess.java b/releasenotes-builder/src/main/java/com/github/checkstyle/MainProcess.java index 09a4e6864..6c06ed0bb 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/MainProcess.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/MainProcess.java @@ -75,7 +75,7 @@ private MainProcess() { * @throws IOException if I/O error occurs. * @throws TemplateException if an error occurs while generating freemarker template. */ - public static List run(Multimap releaseNotes, + public static List runMainProcess(Multimap releaseNotes, CliOptions cliOptions) throws IOException, TemplateException { runPostGeneration(releaseNotes, cliOptions); return runPostPublication(cliOptions); diff --git a/releasenotes-builder/src/main/java/com/github/checkstyle/github/NotesBuilder.java b/releasenotes-builder/src/main/java/com/github/checkstyle/github/NotesBuilder.java index 23728ef0c..00d96f3b1 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/github/NotesBuilder.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/github/NotesBuilder.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; @@ -54,6 +53,7 @@ * * @author Andrei Selkin */ +@SuppressWarnings("deprecation") public final class NotesBuilder { /** Array elements separator. */ @@ -91,6 +91,7 @@ private NotesBuilder() { * @return a map which represents release notes. * @throws IOException if an I/O error occurs. * @throws GitAPIException if an error occurs when accessing Git API. + * @noinspection UseOfSystemOutOrSystemErr */ public static Result buildResult(String localRepoPath, String authToken, String remoteRepoPath, String startRef, String endRef) throws IOException, @@ -149,10 +150,9 @@ private static void buildResultWithLabel(String remoteRepoPath, Result result, final String issueLabel = getIssueLabelFrom(issue); if (issueLabel.isEmpty()) { final String error = String.format(MESSAGE_NO_LABEL, - issueNo, - Arrays.stream(Constants.ISSUE_LABELS) - .collect(Collectors.joining(SEPARATOR)), - remoteRepoPath, issueNo); + issueNo, + String.join(SEPARATOR, Constants.ISSUE_LABELS), + remoteRepoPath, issueNo); result.addError(error); } final List releaseLabels = getAllIssueLabels(issue); @@ -310,7 +310,7 @@ private static Set getCommitsForIssue(Set commits, int iss */ private static String getAuthorsOf(Set commits) { final Set commitAuthors = findCommitAuthors(commits); - return commitAuthors.stream().collect(Collectors.joining(SEPARATOR)); + return String.join(SEPARATOR, commitAuthors); } /** diff --git a/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/MailingListPublisher.java b/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/MailingListPublisher.java index fb15c00cb..c8a2e0528 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/MailingListPublisher.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/MailingListPublisher.java @@ -85,12 +85,12 @@ public MailingListPublisher(String postFilename, String username, String passwor */ public void publish() throws MessagingException, IOException { final Properties props = System.getProperties(); - props.put("mail.smtp.starttls.enable", true); - props.put("mail.smtp.host", SMTP_HOST); - props.put("mail.smtp.user", username); - props.put("mail.smtp.password", password); - props.put("mail.smtp.port", SMTP_PORT); - props.put("mail.smtp.auth", true); + props.setProperty("mail.smtp.starttls.enable", String.valueOf(Boolean.TRUE)); + props.setProperty("mail.smtp.host", SMTP_HOST); + props.setProperty("mail.smtp.user", username); + props.setProperty("mail.smtp.password", password); + props.setProperty("mail.smtp.port", SMTP_PORT); + props.setProperty("mail.smtp.auth", String.valueOf(Boolean.TRUE)); final Session session = Session.getInstance(props, null); final MimeMessage mimeMessage = new MimeMessage(session); diff --git a/releasenotes-builder/src/test/java/com/github/checkstyle/github/CommitMessageTest.java b/releasenotes-builder/src/test/java/com/github/checkstyle/github/CommitMessageTest.java index ce7f635e5..2ad55687a 100644 --- a/releasenotes-builder/src/test/java/com/github/checkstyle/github/CommitMessageTest.java +++ b/releasenotes-builder/src/test/java/com/github/checkstyle/github/CommitMessageTest.java @@ -24,6 +24,9 @@ public class CommitMessageTest { + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testIssue() { final CommitMessage message = new CommitMessage( @@ -31,6 +34,9 @@ public void testIssue() { Assert.assertTrue("Message should match issue/pull pattern", message.isIssueOrPull()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testPull() { final CommitMessage message = new CommitMessage( @@ -38,6 +44,9 @@ public void testPull() { Assert.assertTrue("Message should match issue/pull pattern", message.isIssueOrPull()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testRevert() { final CommitMessage message = new CommitMessage( @@ -52,6 +61,9 @@ public void testRevert() { "5fe5bcee40e39eb6a23864f7f55128cbf2f10641", message.getRevertedCommitReference()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testRevertNotInBeginningOfMessage() { final CommitMessage message = new CommitMessage( @@ -61,6 +73,9 @@ public void testRevertNotInBeginningOfMessage() { Assert.assertTrue("Message should match revert pattern", message.isRevert()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testReleaseIsIgnored() { final CommitMessage message = new CommitMessage( @@ -68,6 +83,9 @@ public void testReleaseIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testUpdateToIsIgnored() { final CommitMessage message = new CommitMessage( @@ -75,6 +93,9 @@ public void testUpdateToIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testDocReleaseNotesIsIgnored() { final CommitMessage message = new CommitMessage( @@ -82,6 +103,9 @@ public void testDocReleaseNotesIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testConfigIsIgnored() { final CommitMessage message = new CommitMessage( @@ -89,6 +113,9 @@ public void testConfigIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testDependencyIsIgnored() { final CommitMessage message = new CommitMessage( @@ -111,6 +138,9 @@ public void testDependencyIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testInfraIsIgnored() { final CommitMessage message = new CommitMessage( @@ -118,6 +148,9 @@ public void testInfraIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testMinorIsIgnored() { final CommitMessage message = new CommitMessage( @@ -125,6 +158,9 @@ public void testMinorIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testSupplementalIsIgnored() { final CommitMessage message = new CommitMessage( @@ -132,6 +168,9 @@ public void testSupplementalIsIgnored() { Assert.assertTrue("Message should match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testMarkersNotInBeginningOfMessage() { final CommitMessage message = new CommitMessage( @@ -148,6 +187,9 @@ public void testMarkersNotInBeginningOfMessage() { Assert.assertFalse("Message should not match ignore pattern", message.isIgnored()); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testUnclassifiedCommit() { final CommitMessage message = new CommitMessage( diff --git a/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java b/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java index 1bf8ccfa8..1953d5b85 100644 --- a/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java +++ b/releasenotes-builder/src/test/java/com/github/checkstyle/templates/TemplateProcessorTest.java @@ -60,9 +60,12 @@ public void setup() throws IOException { temporaryFolder.create(); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyBreakingCompatibility() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions() .setGenerateAll(true).build()); @@ -75,9 +78,12 @@ public void testGenerateOnlyBreakingCompatibility() throws Exception { assertFile("githubPageBreakingCompatibility.txt", MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyNewFeature() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(null, createAllNotes(), null, null, null), createBaseCliOptions() .setGenerateAll(true).build()); @@ -90,9 +96,12 @@ public void testGenerateOnlyNewFeature() throws Exception { assertFile("githubPageNew.txt", MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyBug() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(null, null, createAllNotes(), null, null), createBaseCliOptions() .setGenerateAll(true).build()); @@ -105,9 +114,12 @@ public void testGenerateOnlyBug() throws Exception { assertFile("githubPageBug.txt", MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyMisc() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(null, null, null, createAllNotes(), null), createBaseCliOptions() .setGenerateAll(true).build()); @@ -119,9 +131,12 @@ public void testGenerateOnlyMisc() throws Exception { assertFile("rssMlistMisc.txt", MainProcess.MLIST_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyNewModule() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(null, null, null, null, createAllNotes()), createBaseCliOptions() .setGenerateAll(true).build()); @@ -134,9 +149,12 @@ public void testGenerateOnlyNewModule() throws Exception { assertFile("githubPageNew.txt", MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateAll() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes( Collections.singletonList(createReleaseNotesMessage("Title 1", "Author 1")), Collections.singletonList(createReleaseNotesMessage(2, "Title 2", "Author 2")), @@ -154,9 +172,12 @@ public void testGenerateAll() throws Exception { assertFile("githubPageAll.txt", MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyXdoc() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions() .setGenerateXdoc(true).build()); @@ -169,9 +190,12 @@ public void testGenerateOnlyXdoc() throws Exception { assertFile(MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyTwitter() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions() .setGenerateTw(true).build()); @@ -184,9 +208,12 @@ public void testGenerateOnlyTwitter() throws Exception { assertFile(MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyRss() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions() .setGenerateRss(true).build()); @@ -199,9 +226,12 @@ public void testGenerateOnlyRss() throws Exception { assertFile(MainProcess.GITHUB_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyMlist() throws Exception { - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions() .setGenerateMlist(true).build()); @@ -214,6 +244,9 @@ public void testGenerateOnlyMlist() throws Exception { assertFile("rssMlistBreakingCompatibility.txt", MainProcess.MLIST_FILENAME); } + /** + * @noinspection JUnitTestMethodWithNoAssertions + */ @Test public void testGenerateOnlyGitHub() throws Exception { final List errors = MainProcess.run( @@ -235,7 +268,7 @@ public void testGenerateCustomTemplate() throws Exception { FileUtils.writeStringToFile(file, "hello world"); final String template = file.getAbsolutePath(); - final List errors = MainProcess.run( + final List errors = MainProcess.runMainProcess( createNotes(createAllNotes(), createAllNotes(), createAllNotes(), createAllNotes(), createAllNotes()), createBaseCliOptions().setGenerateAll(true).setXdocTemplate(template) @@ -328,15 +361,17 @@ private void assertFile(String expectedName, String actualName) throws IOExcepti .format(DateTimeFormatter.ofPattern("dd.MM.yyyy", Locale.US)), "XX.XX.XXXX"); - Assert.assertEquals(expectedXdoc, actualXdoc); + Assert.assertEquals("Actual filename does not match expected filename", + expectedXdoc, actualXdoc); } private void assertFile(String actualName) { - Assert.assertFalse(new File(temporaryFolder.getRoot(), actualName).exists()); + Assert.assertFalse("File does not exist.", + new File(temporaryFolder.getRoot(), actualName).exists()); } private static String getFileContents(File file) throws IOException { - final StringBuilder result = new StringBuilder(); + final StringBuilder result = new StringBuilder(1024); try (BufferedReader br = Files.newBufferedReader(file.toPath())) { do {