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 Jul 4, 2022
1 parent e532f8a commit 717e66b
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 28 deletions.
4 changes: 2 additions & 2 deletions releasenotes-builder/config/checkstyle.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private Main() {
* Entry point.
*
* @param args command line arguments.
* @noinspection UseOfSystemOutOrSystemErr, CallToSystemExit
*/
public static void main(String... args) {
int errorCounter;
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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<String> entities) {
System.out.println();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 @@ -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;
Expand All @@ -53,6 +52,7 @@
*
* @author Andrei Selkin
*/
@SuppressWarnings("deprecation")
public final class NotesBuilder {

/** Array elements separator. */
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ private static Set<RevCommit> getCommitsForIssue(Set<RevCommit> commits, int iss
*/
private static String getAuthorsOf(Set<RevCommit> commits) {
final Set<String> commitAuthors = findCommitAuthors(commits);
return commitAuthors.stream().collect(Collectors.joining(SEPARATOR));
return String.join(SEPARATOR, commitAuthors);
}

/**
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 @@ -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) {
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
Loading

0 comments on commit 717e66b

Please sign in to comment.