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 596137563..b42bca639 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/MainProcess.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/MainProcess.java @@ -71,7 +71,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 3fbb5419a..919aac58c 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 @@ -27,7 +27,6 @@ import java.util.HashSet; 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; @@ -53,6 +52,7 @@ * * @author Andrei Selkin */ +@SuppressWarnings("deprecation") public final class NotesBuilder { /** Array elements separator. */ @@ -85,6 +85,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, GitAPIException { @@ -120,8 +121,7 @@ public static Result buildResult(String localRepoPath, String authToken, String if (issueLabel.isEmpty()) { final String error = String.format(MESSAGE_NO_LABEL, issueNo, - Arrays.stream(Constants.ISSUE_LABELS) - .collect(Collectors.joining(SEPARATOR)), + String.join(SEPARATOR, Constants.ISSUE_LABELS), remoteRepoPath, issueNo); result.addError(error); } @@ -272,7 +272,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/main/java/com/github/checkstyle/publishers/XdocPublisher.java b/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/XdocPublisher.java index 9a488a902..d40ede062 100644 --- a/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/XdocPublisher.java +++ b/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/XdocPublisher.java @@ -72,6 +72,7 @@ public class XdocPublisher { * @param releaseNumber release number. * @param doPush whether to do push. * @param authToken auth token for Github. + * @noinspection BooleanParameter */ public XdocPublisher(String postFilename, String localRepoPath, String releaseNumber, boolean doPush, String authToken) { 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..4e720e2ec 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 @@ -22,6 +22,11 @@ import org.junit.Assert; import org.junit.Test; +/** + * Tests commit message structure. + * + * @noinspection JUnitTestMethodWithNoAssertions + */ public class CommitMessageTest { @Test 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 271c8ac7c..55f4fb653 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 @@ -49,6 +49,11 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; +/** + * Tests release notes template processing. + * + * @noinspection JUnitTestMethodWithNoAssertions + */ public class TemplateProcessorTest { @Rule @@ -62,7 +67,7 @@ public void setup() throws IOException { @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()); @@ -76,7 +81,7 @@ public void testGenerateOnlyBreakingCompatibility() throws Exception { @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,7 +95,7 @@ public void testGenerateOnlyNewFeature() throws Exception { @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()); @@ -104,7 +109,7 @@ public void testGenerateOnlyBug() throws Exception { @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()); @@ -118,7 +123,7 @@ public void testGenerateOnlyMisc() throws Exception { @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()); @@ -132,7 +137,7 @@ public void testGenerateOnlyNewModule() throws Exception { @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")), @@ -151,7 +156,7 @@ public void testGenerateAll() throws Exception { @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()); @@ -165,7 +170,7 @@ public void testGenerateOnlyXdoc() throws Exception { @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()); @@ -179,7 +184,7 @@ public void testGenerateOnlyTwitter() throws Exception { @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()); @@ -193,7 +198,7 @@ public void testGenerateOnlyRss() throws Exception { @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()); @@ -211,7 +216,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) @@ -302,15 +307,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 {