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

Disallow dangling parenthesis #687

Merged
merged 5 commits into from
Jul 15, 2019
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