From f1f3c453ccefabc6b87dae0aa0c5aec2f9023360 Mon Sep 17 00:00:00 2001 From: Nick Mancuso Date: Sat, 2 Jul 2022 10:02:29 -0400 Subject: [PATCH] Issue #614: Suppress all Idea Inspection violations --- .../com/github/checkstyle/MainProcess.java | 2 +- .../publishers/MailingListPublisher.java | 12 ++-- .../checkstyle/github/CommitMessageTest.java | 42 +++++++++++++ .../templates/TemplateProcessorTest.java | 63 ++++++++++++++----- 4 files changed, 98 insertions(+), 21 deletions(-) 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 09a4e686..6c06ed0b 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/publishers/MailingListPublisher.java b/releasenotes-builder/src/main/java/com/github/checkstyle/publishers/MailingListPublisher.java index fb15c00c..c8a2e052 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 ce7f635e..2ad55687 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 1bf8ccfa..1953d5b8 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 {