From d2b87b24b69b56d112fda50327416b9c66ee3ea2 Mon Sep 17 00:00:00 2001 From: iamdanfox Date: Mon, 3 Feb 2020 14:39:17 +0000 Subject: [PATCH] Turn off ParenPad when p-j-f enabled (#1205) Checkstyle's `ParenPad` rule is turned off when using palantir-java-format, to avoid disagreements that can't be fixed by the user. --- changelog/@unreleased/pr-1205.v2.yml | 6 ++++++ .../baseline/plugins/BaselineConfig.java | 16 ++++++++++------ .../BaselineConfigIntegrationTest.groovy | 3 +++ 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 changelog/@unreleased/pr-1205.v2.yml diff --git a/changelog/@unreleased/pr-1205.v2.yml b/changelog/@unreleased/pr-1205.v2.yml new file mode 100644 index 000000000..92c905cb7 --- /dev/null +++ b/changelog/@unreleased/pr-1205.v2.yml @@ -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 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineConfig.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineConfig.java index b44ab31c4..4585935bc 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineConfig.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineConfig.java @@ -98,12 +98,16 @@ public void execute(Task task) { try { String contents = new String(Files.readAllBytes(checkstyleXml), StandardCharsets.UTF_8); String replaced = contents.replace( - " " - + "\n" - + " \n" - + " \n" - + " \n", - ""); + " " + + "\n" + + " \n" + + " \n" + + " \n", + "") + .replace( + " \n", + ""); Preconditions.checkState(!contents.equals(replaced), "Patching checkstyle.xml must make a change"); Files.write(checkstyleXml, replaced.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineConfigIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineConfigIntegrationTest.groovy index 439cd9611..d0de6364a 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineConfigIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineConfigIntegrationTest.groovy @@ -149,5 +149,8 @@ class BaselineConfigIntegrationTest extends AbstractPluginTest { !new File(projectDir, '.baseline/checkstyle/checkstyle.xml').readLines().any { it.contains '' } + !new File(projectDir, '.baseline/checkstyle/checkstyle.xml').readLines().any { + it.contains '' + } } }