Skip to content
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-687.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: improvement
improvement:
description: |-
Spotless check for disallowing dangling parenthesis.
links:
- https://github.com/palantir/gradle-baseline/pull/687
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public void apply(Project project) {

// No empty lines at start of blocks
java.replaceRegex("Block starts with blank lines", "\\) \\{\n+", ") {\n");

// No dangling parentheses - closing paren must be on the same line as the expression
java.replaceRegex("Dangling closing parenthesis", "(\n\\s+)+\\)", ")");
});

// necessary because SpotlessPlugin creates tasks in an afterEvaluate block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class BaselineFormatIntegrationTest extends AbstractPluginTest {
package test;
public class Test { void test() {
int x = 1;
System.out.println(
"Hello");
Optional.of("hello").orElseGet(() -> {
return "Hello World";
});
} }
'''.stripIndent()

Expand All @@ -48,6 +53,12 @@ class BaselineFormatIntegrationTest extends AbstractPluginTest {


int x = 1;
System.out.println(
"Hello"
);
Optional.of("hello").orElseGet(() -> {
return "Hello World";
});
} }
'''.stripIndent()

Expand Down