Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off ParenPad when p-j-f enabled #1205

Merged
merged 3 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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">'
}
}
}