Skip to content

Commit

Permalink
Issue checkstyle#614: Suppress all Idea Inspection violations
Browse files Browse the repository at this point in the history
  • Loading branch information
nrmancuso committed Aug 29, 2022
1 parent c8e12da commit f1f3c45
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> run(Multimap<String, ReleaseNotesMessage> releaseNotes,
public static List<String> runMainProcess(Multimap<String, ReleaseNotesMessage> releaseNotes,
CliOptions cliOptions) throws IOException, TemplateException {
runPostGeneration(releaseNotes, cliOptions);
return runPostPublication(cliOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,29 @@

public class CommitMessageTest {

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testIssue() {
final CommitMessage message = new CommitMessage(
"Issue #1487: workaround for cobertura at CheckstyleAntTask.java to get 100% coverage");
Assert.assertTrue("Message should match issue/pull pattern", message.isIssueOrPull());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testPull() {
final CommitMessage message = new CommitMessage(
"Pull #9314: fix escaped char pattern in AvoidEscapedUnicodeCharactersCheck");
Assert.assertTrue("Message should match issue/pull pattern", message.isIssueOrPull());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testRevert() {
final CommitMessage message = new CommitMessage(
Expand All @@ -52,6 +61,9 @@ public void testRevert() {
"5fe5bcee40e39eb6a23864f7f55128cbf2f10641", message.getRevertedCommitReference());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testRevertNotInBeginningOfMessage() {
final CommitMessage message = new CommitMessage(
Expand All @@ -61,34 +73,49 @@ public void testRevertNotInBeginningOfMessage() {
Assert.assertTrue("Message should match revert pattern", message.isRevert());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testReleaseIsIgnored() {
final CommitMessage message = new CommitMessage(
"[maven-release-plugin] prepare release checkstyle-8.35");
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testUpdateToIsIgnored() {
final CommitMessage message = new CommitMessage(
"update to 7.0-SNAPSHOT");
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testDocReleaseNotesIsIgnored() {
final CommitMessage message = new CommitMessage(
"doc: release notes 8.43");
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testConfigIsIgnored() {
final CommitMessage message = new CommitMessage(
"config: update to 8.42-SNAPSHOT");
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testDependencyIsIgnored() {
final CommitMessage message = new CommitMessage(
Expand All @@ -111,27 +138,39 @@ public void testDependencyIsIgnored() {
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testInfraIsIgnored() {
final CommitMessage message = new CommitMessage(
"infra: update README to have links to travis.com");
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testMinorIsIgnored() {
final CommitMessage message = new CommitMessage(
"minor: refactor boolean expression to fix TC build");
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testSupplementalIsIgnored() {
final CommitMessage message = new CommitMessage(
"supplemental: divide description into paragraph for Issue #8928");
Assert.assertTrue("Message should match ignore pattern", message.isIgnored());
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testMarkersNotInBeginningOfMessage() {
final CommitMessage message = new CommitMessage(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ public void setup() throws IOException {
temporaryFolder.create();
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testGenerateOnlyBreakingCompatibility() throws Exception {
final List<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions()
.setGenerateAll(true).build());

Expand All @@ -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<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(null, createAllNotes(), null, null, null), createBaseCliOptions()
.setGenerateAll(true).build());

Expand All @@ -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<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(null, null, createAllNotes(), null, null), createBaseCliOptions()
.setGenerateAll(true).build());

Expand All @@ -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<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(null, null, null, createAllNotes(), null), createBaseCliOptions()
.setGenerateAll(true).build());

Expand All @@ -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<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(null, null, null, null, createAllNotes()), createBaseCliOptions()
.setGenerateAll(true).build());

Expand All @@ -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<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(
Collections.singletonList(createReleaseNotesMessage("Title 1", "Author 1")),
Collections.singletonList(createReleaseNotesMessage(2, "Title 2", "Author 2")),
Expand All @@ -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<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions()
.setGenerateXdoc(true).build());

Expand All @@ -169,9 +190,12 @@ public void testGenerateOnlyXdoc() throws Exception {
assertFile(MainProcess.GITHUB_FILENAME);
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testGenerateOnlyTwitter() throws Exception {
final List<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions()
.setGenerateTw(true).build());

Expand All @@ -184,9 +208,12 @@ public void testGenerateOnlyTwitter() throws Exception {
assertFile(MainProcess.GITHUB_FILENAME);
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testGenerateOnlyRss() throws Exception {
final List<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions()
.setGenerateRss(true).build());

Expand All @@ -199,9 +226,12 @@ public void testGenerateOnlyRss() throws Exception {
assertFile(MainProcess.GITHUB_FILENAME);
}

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void testGenerateOnlyMlist() throws Exception {
final List<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(createAllNotes(), null, null, null, null), createBaseCliOptions()
.setGenerateMlist(true).build());

Expand All @@ -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<String> errors = MainProcess.run(
Expand All @@ -235,7 +268,7 @@ public void testGenerateCustomTemplate() throws Exception {
FileUtils.writeStringToFile(file, "hello world");
final String template = file.getAbsolutePath();

final List<String> errors = MainProcess.run(
final List<String> errors = MainProcess.runMainProcess(
createNotes(createAllNotes(), createAllNotes(), createAllNotes(), createAllNotes(),
createAllNotes()),
createBaseCliOptions().setGenerateAll(true).setXdocTemplate(template)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f1f3c45

Please sign in to comment.