Skip to content

Commit

Permalink
Turn off ParenPad when p-j-f enabled (#1205)
Browse files Browse the repository at this point in the history
Checkstyle's `ParenPad` rule is turned off when using palantir-java-format, to avoid disagreements that can't be fixed by the user.
  • Loading branch information
iamdanfox authored Feb 3, 2020
1 parent c8cc5c4 commit d2b87b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1205.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: Checkstyle's `ParenPad` rule is turned off when using palantir-java-format,
to avoid disagreements that can't be fixed by the user.
links:
- https://github.com/palantir/gradle-baseline/pull/1205
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ public void execute(Task task) {
try {
String contents = new String(Files.readAllBytes(checkstyleXml), StandardCharsets.UTF_8);
String replaced = contents.replace(
" <module name=\"Indentation\"> "
+ "<!-- Java Style Guide: Block indentation: +4 spaces -->\n"
+ " <property name=\"arrayInitIndent\" value=\"8\"/>\n"
+ " <property name=\"lineWrappingIndentation\" value=\"8\"/>\n"
+ " </module>\n",
"");
" <module name=\"Indentation\"> "
+ "<!-- Java Style Guide: Block indentation: +4 spaces -->\n"
+ " <property name=\"arrayInitIndent\" value=\"8\"/>\n"
+ " <property name=\"lineWrappingIndentation\" value=\"8\"/>\n"
+ " </module>\n",
"")
.replace(
" <module name=\"ParenPad\"/> <!-- Java Style Guide: Horizontal whitespace"
+ " -->\n",
"");
Preconditions.checkState(!contents.equals(replaced), "Patching checkstyle.xml must make a change");
Files.write(checkstyleXml, replaced.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,8 @@ class BaselineConfigIntegrationTest extends AbstractPluginTest {
!new File(projectDir, '.baseline/checkstyle/checkstyle.xml').readLines().any {
it.contains '<module name="Indentation">'
}
!new File(projectDir, '.baseline/checkstyle/checkstyle.xml').readLines().any {
it.contains '<module name="ParenPad">'
}
}
}

0 comments on commit d2b87b2

Please sign in to comment.