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 2, 2022
1 parent e532f8a commit 0ff9542
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 26 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
*/
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", Boolean.TRUE.toString());
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", Boolean.TRUE.toString());

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 @@ -22,6 +22,9 @@
import org.junit.Assert;
import org.junit.Test;

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
public class CommitMessageTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;

/**
* @noinspection JUnitTestMethodWithNoAssertions
*/
public class TemplateProcessorTest {

@Rule
Expand All @@ -62,7 +65,7 @@ public void setup() throws IOException {

@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 @@ -76,7 +79,7 @@ public void testGenerateOnlyBreakingCompatibility() throws Exception {

@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,7 +93,7 @@ public void testGenerateOnlyNewFeature() throws Exception {

@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 @@ -104,7 +107,7 @@ public void testGenerateOnlyBug() throws Exception {

@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 @@ -118,7 +121,7 @@ public void testGenerateOnlyMisc() throws Exception {

@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 @@ -132,7 +135,7 @@ public void testGenerateOnlyNewModule() throws Exception {

@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 @@ -151,7 +154,7 @@ public void testGenerateAll() throws Exception {

@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 @@ -165,7 +168,7 @@ public void testGenerateOnlyXdoc() throws Exception {

@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 @@ -179,7 +182,7 @@ public void testGenerateOnlyTwitter() throws Exception {

@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 @@ -193,7 +196,7 @@ public void testGenerateOnlyRss() throws Exception {

@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 @@ -211,7 +214,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 @@ -310,7 +313,7 @@ private void assertFile(String actualName) {
}

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 0ff9542

Please sign in to comment.