choco-solver
choco-solver copied to clipboard
Should provide code formatting rules
Like with Checkstyle
I evaluated Checktyle default rules, it detects 23604 items in 570 files (almost all of them). A little configuration is necessary.
I think that by default, it uses Sun recommendation while Intellij uses its own. My advice is “uses something that matches what you do since 10 years :D”
Le 14 sept. 2016 à 18:01, Choco Team [email protected] a écrit :
Like with Checkstyle
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Fabien Hermenier Associate Professor SCALE Project, University Nice Sophia Antipolis http://fhermeni.github.io
That's what I had in mind ;)
Beside checkstyle, you could also provide custom formatter for Eclipse and IntellijIdea. However, I hope that it is doable (see here).
It is maybe not as difficult as it was (see this post).
maven can be configured with a formatter plugin. this plugin needs to have a project specifically to import the formatter.xml into the other projects too, which is bad IMO ( http://code.revelc.net/formatter-maven-plugin/formatter-maven-plugin/examples.html#Multimodule_Configuration ) Once this plugin is installed, every time you compile your code will be formatted. The plugin memorizes the hashes of the java file before formatting them again.
I'll play around with the plugin on a private branch to test it.
I played with formatter-maven-plugin and was not entirely satisfied with the process. I read that it is better to give rules (for instance, checkstyle-based ones) instead of auto-formatting code. So, I will provide a check style-checker XML file and an IntelliJ IDEA code style scheme that auto format code (one may want to provide the same file for Eclipse). These files will then updated until we reach a fix point since some rules can be discussed.
Here is a few related links :
- https://github.com/HPI-Information-Systems/Metanome/wiki/Installing-the-google-styleguide-settings-in-intellij-and-eclipse
- https://github.com/krasa/EclipseCodeFormatter
- https://blog.jetbrains.com/idea/2014/10/intellij-idea-14-will-detect-code-styles-on-the-fly/
- https://plugins.jetbrains.com/plugin/6546
Good luck !
Luck is the right word
Well, I finally succeed to make formatter-maven-plugin works (@glelouet: thank you) and started a formatter file. That is not enough, but that is a good start. I will now try to configure a Checkstyle.xml file to share too.
What about using google-java-format ?
I believe that it is a good idea if you like their code style. The first link of my previous post show that their style can be easily integrated within intellij and eclipse.
That would be a good point if we are able to override some of the rules easily
I like the last one since it seems to be an active projet from google
I tested their maven plugin and since:
- the projet is active,
- the google code style is wide spread,
- the google code style is not far away from what we've done since (i.e., few modifications), and
- I don't feel like designing our own rules, I vote for this solution.
I suggest to update pom.xml
just before the next release.
Let's go for the google code style ! I will give you feedback after the eclipse integration.
Strangely, the maven plugin does not modified files like google-java-format, even though it seems based on it. So, a first step would be to simply use the maven plugin and wait for any updates.
FYI: following these steps I imported intellij-java-google-style.xml in IntelliJ IDEA (configuration files for other IDE can be found here).
I looked at google java format and found that indentation of only 2 spaces instead ordinary 4 spaces is used. I have warn you that 2 spaces are not good, my experience with a lot of levels in foreign code is very bad for readability.
Thank you for your feedbacks. Actually, I'm still not convinced by tools I found so far, so I probably wait for a maven-like tool, customizable.