Skip to content

Test try-with-resources against "Only one statement per line" checkstyle rule #136

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

Closed
philwebb opened this issue Jul 25, 2019 · 1 comment
Milestone

Comments

@philwebb
Copy link
Contributor

See spring-projects/spring-boot#17637 and #113 (comment) for more details.


I have the following code:

try (Session session = this.driver.session();
		Transaction tx = session.beginTransaction()) {
		// Do something
}

Spring Java Format complains

 Formatting violations found in the following files:
 * /Users/msimons/Projects/spring-projects/spring-boot/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/neo4j/Neo4jDriverAutoConfigurationIntegrationTests.java

Run `spring-javaformat:apply` to fix.

Fix turns the snippet into

try (Session session = this.driver.session(); Transaction tx = session.beginTransaction()) {
}

Checkstyle complains OneStatementPerLine.

I have no clue how to format the thing.

@philwebb philwebb added this to the 0.0.x milestone Dec 4, 2019
@philwebb philwebb modified the milestones: 0.0.x, 0.0.26 Dec 4, 2020
@philwebb philwebb changed the title Formatter conflicts with "Only one statement per line" checkstyle rule Test try-with-resources against "Only one statement per line" checkstyle rule Dec 4, 2020
@philwebb
Copy link
Contributor Author

philwebb commented Dec 4, 2020

The checkstyle fix has solved this. I've added a test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant