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 2 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
25 changes: 25 additions & 0 deletions changelog/@unreleased/pr-687.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
type: improvement
improvement:
description: |-
Disallow dangling parenthesis
gatesn marked this conversation as resolved.
Show resolved Hide resolved

## Before this PR
Generally our style has always been to disallow dangling parenthesis, but nothing applies this rule.

The aim of this PR, and any style PR, is to increase consistency of coding style and reduce time spent in CR commenting with stylistic nit picks.

```java
Preconditions.checkArgument(
myExpression,
"My expression isn't as true as it should be"
);
```

## After this PR
```java
Preconditions.checkArgument(
myExpression,
"My expression isn't as true as it should be");
```
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,8 @@ class BaselineFormatIntegrationTest extends AbstractPluginTest {
package test;
public class Test { void test() {
int x = 1;
System.out.println(
"Hello");
} }
'''.stripIndent()

Expand All @@ -48,6 +50,9 @@ class BaselineFormatIntegrationTest extends AbstractPluginTest {


int x = 1;
System.out.println(
"Hello"
);
gatesn marked this conversation as resolved.
Show resolved Hide resolved
} }
'''.stripIndent()

Expand Down