Put code style settings for IntelliJ IDEA under version control #426

Open
peterdemaeyer opened this Issue Apr 27, 2012 · 20 comments

5 participants

@peterdemaeyer

It would be convenient to enforce code style conventions (like imports) by committing them as Eclipse 'project specific settings' into the VCS. The Eclipse project settings are already under version control anyway. That way, new and unwary developers that wish to contribute to the project automatically use the correct code style.

@awulder

I've submitted some pull requests and I've noticed that the code style is very inconsistent. For example the use of curly brackets, indenting and some other things. I see code style as part of code qualtiy. Is it possible that the JUnit team commits the code style settings to keep the quality high?

@dsaff
JUnit member

The formatting settings are already committed for Eclipse users:

https://github.com/KentBeck/junit/blob/master/.settings/org.eclipse.jdt.core.prefs

Do you think we should require submitters to import the project to Eclipse for formatting? I could certainly go along with that.

@awulder

I've overlooked the Eclipse file :) I use Intellij IDEA. Is it an option to commit the a formatting file for Intellij IDEA as well?
I think you should require submitters to use the formatting file to keep the code style conistent.

@dsaff
JUnit member

I think it could be really useful if someone took a look at the style of especially most of the junit.framework classes, and found formatter settings for IDEA that would maintain them. I'd be happy to accept such a patch.

@awulder

I will see what I can do

@awulder

Is it possible to change the code style a bit like the missing space before the equal sign?

@dsaff
JUnit member

Arjan,

Yes, I'd be open to that (the current style is, I believe, an amalgam between IBM Java style and SmallTalk.) But I'd want to update all the code to the new style at once, which would be quite an undertaking.

@awulder

I understand that you want to update all the code at once but I think that with the IDE nowadays that it isn't a problem.
Maybe we can use the standard sun coding conventions and add checkstyle to the Ant build file that checks the code?

@dsaff
JUnit member

I'm not sure what you mean by "isn't a problem". If we adjust the formatting rules without also bringing the code into line, we'll end up with a situation where > 50% of the lines in each change are just adjusting whitespace, which is hard to review.

@awulder

What I actually mean is that it's easy with the modern IDE's the apply a (new) coding style to a whole project. So reformatting the current code base is not difficult.

@dsaff
JUnit member
@awulder

I reformatted the code (indenting, use of curly braces, use of whitespace) and then I ran Checkstyle with the sun_checks.xml configuration file. There are 3342 violations. A lot of line length and javadoc style violations. There are also al lot of warnings about parameters that should be final.

Before submitting a pull request I think it must be clear how to deal with these violations. One approach is to modify the sun_checks.xml file to disable the checks that are irrelevant to the JUnit team or another approach can be to deal with all these warnings. I would actually have choosen the first approach.

Or just leave out the checkstyle check :)

@awulder awulder pushed a commit to awulder/junit that referenced this issue Aug 22, 2012
Arjan Wulder issue #426 new consistent coding style
Reformatted the code base for an consistent coding/formatting style
aad05c6
@awulder awulder pushed a commit to awulder/junit that referenced this issue Sep 8, 2012
Arjan Wulder issue #426 Description of the coding style
Issue #426 Description of the coding style
dc3d4d4
@awulder awulder pushed a commit to awulder/junit that referenced this issue Sep 12, 2012
Arjan Wulder Issue #426 Removed confusing whitespaces
Issue #426 Removed confusing whitespaces.
3dbb0b3
@awulder awulder pushed a commit to awulder/junit that referenced this issue Sep 13, 2012
Arjan Wulder Issue #426 Added suggestions by dsaff
Removed the Markdown syntax, changed import order and removed confusing
Maximum Blank Lines section.
ab1eb66
@awulder awulder pushed a commit to awulder/junit that referenced this issue Sep 27, 2012
Arjan Wulder Issue #426 Added suggestions by dsaff
- Do not align JavaDoc parameter description
- Removed "Keep empty .. JavaDoc tag"
- corrected typp
2ac2500
@awulder awulder pushed a commit to awulder/junit that referenced this issue Oct 4, 2012
Arjan Wulder Issue #426 Applied new coding style
Applied the new coding style to the code base for issue #426.
30f2b16
@marcphilipp
JUnit member

Fixed by #522.

@marcphilipp marcphilipp closed this Oct 6, 2012
@dsaff
JUnit member

Arjan,

Do you currently have an Eclipse formatter settings file that we can check in to help others who want to follow this style? Thanks.

@marcphilipp
JUnit member

Oops, sorry, I thought those were committed in #522. Reopening the issue...

@marcphilipp marcphilipp reopened this Oct 24, 2012
@marcphilipp
JUnit member

@awulder Ping!

@awulder

@marcphilipp I've been very busy lately. I don't use Eclipse but I will commit the formatter setting for Eclipse and Intellij IDEA.

@marcphilipp
JUnit member

@awulder Sounds good! If you don't find enough time, please let us know. It would be great to finally make formatting a non-issue in pull requests.

@marcphilipp
JUnit member

@awulder Have you started to work on this or should someone else take over?

@Tibor17

Does anybody have a spare time to check the *.prefs files in .settings folder if matching the CODING_STYLE?
Possibly update it.
Thx.

@kcooney kcooney changed the title from Put code style settings under version control to Put code style settings for IntelliJ IDEA under version control Jul 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment