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

Code base doesn't comply with JUnit's own coding style #1350

Open
PeterWippermann opened this issue Jul 24, 2016 · 7 comments
Open

Code base doesn't comply with JUnit's own coding style #1350

PeterWippermann opened this issue Jul 24, 2016 · 7 comments
Assignees
Labels

Comments

@PeterWippermann
Copy link
Contributor

PeterWippermann commented Jul 24, 2016

I'd like to suggest to reformat all code under org.junit.* once to meet the defined formatting guidelines.

At the moment not all the files are formatted accordingly to that standard. This causes problems for contributors - especially in pull request. If you format the code you get a lot of extraneous diffs - just because of the reformatting - in addition to your actual changes.

I think it's not too late to do this formatting.
Regarding existing PRs that tried to preserve the outdated styling: They would get extraneous diffs then of course, but if they apply the new format as well everything would be fine again. In addition, I think many of PRs are dead anyway, since many of them haven't seen any updates for months or even years.

As a result, contributing to JUnit 4 and reviewing the changes by the core team should become easier in the future.

@kcooney
Copy link
Member

kcooney commented Jul 24, 2016

If you can find a way to guarantee that new code will use the new formatting regardless of what editor they use (for instance, with Spotless) then I'd be fine doing a reformat.

@PeterWippermann
Copy link
Contributor Author

All I can do is: import Google's code style in Eclipse. Change 2 space indentantion to 4 spaces. And run the formatting over all affected files.

@Stephan202
Copy link
Contributor

A non-Eclipse solution could be to use google-java-format. There's also a googleformatter-maven-plugin.

@kcooney
Copy link
Member

kcooney commented Jul 24, 2016

Thanks, @Stephan202

I'm going on vacation for a few days, but hopefully I can look into the Maven plugin next weekend.

@kcooney kcooney self-assigned this Jul 24, 2016
@tomwhoiscontrary
Copy link
Contributor

JUnit uses the Google style with the exception of different indentation.

The google-java-format tool doesn't support overriding the indentation.

If you want to enforce the style after reformatting, the tool of choice would be Checkstyle, via its Maven plugin. This supports using the Google style as a built-in custom configuration. Again, there's no way to override the indentation. You could use a modified copy of the configuration file, but that's under LGPL, so you immediately run into a license nightmare.

Would you consider dropping the indentation exception? If so, automating everything becomes fairly easy. Although you would then change every file.

@PeterWippermann
Copy link
Contributor Author

Great effort, @tomwhoiscontrary ! 👍

@Stephan202
Copy link
Contributor

The google-java-format tool doesn't support overriding the indentation.

I added a comment on PR #1379; seems four space indentation should be possible after all :).

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

No branches or pull requests

4 participants