[keycloak-dev] Code style

Peter Palaga ppalaga at redhat.com
Thu Jan 21 16:08:21 EST 2016


Hi *,

I can serve with some experience gathered in Hawkular:

General:
* Rules that are not enforced by the build process are often ignored
* Having such rules for license headers and code style saves time
   during reviews
* Newcomers are told what to do automatically
* Having such rules reduces the amount of formatting changes that may
   be seen as pollution of the history

The implementation in Hawkular:
* Checkstyle ruleset for Java files [1], taken from WildFly, with minor 
modifications (120 char max line length instead of 100, explicit import 
order, ...) [2]
* Checkstyle rules for all text files (xml, json, ...) for banning tabs 
as indentation characters and for banning trailing whitespace [3]
* Newly, 2-space indentation for XML files checked by xml-maven-plugin [4]
* com.mycila:license-maven-plugin for license headers [5]
* Our UI guys have their own tslint rules


IDEs:
* Maven rules define the standard, IDE configs are derived
* IDE configs [6] consitent with the Maven rules are possible and mostly 
work well.
* We have them only for Eclipse and IJ



[1] 
https://github.com/hawkular/hawkular-build-tools/blob/master/build-tools/src/main/resources/hawkular-checkstyle/checkstyle.xml#L39
[2] https://github.com/hawkular/hawkular-parent-pom/blob/master/pom.xml#L844
[3] 
https://github.com/hawkular/hawkular-build-tools/blob/master/build-tools/src/main/resources/hawkular-checkstyle/checkstyle.xml#L29-L37
[4] 
https://github.com/hawkular/hawkular-parent-pom/blob/master/pom.xml#L1020
[5] https://github.com/hawkular/hawkular-parent-pom/blob/master/pom.xml#L844
[6] https://github.com/hawkular/hawkular-build-tools/tree/master/ide-configs

Best,

Peter

On 2016-01-21 21:25, Stan Silvert wrote:
> On 1/21/2016 2:28 PM, Stian Thorgersen wrote:
>> I'm wasn't planing on having a lengthy discussion about code style.
>> It's usually just a matter of personal preference and folks do get
>> used to most things.
>>
>> Questions are:
>>
>> * Should we have a code style?
> I've seen too many teams waste time arguing about code style.  I think
> that our team is mature enough that we wouldn't let that happen, but
> having strict enforcement never seems to provide much payoff, imo.
>
> I think a middle ground is to just publish some general guidelines of
> basic standards we can all agree with.  Then if someone strays too far,
> just ask them to fix it.
>> * What IDEs are Keycloak devs using (I'm crossing my fingers everyone
>> says IntelliJ)
> NetBeans
>> * Should we enable the checkstyle plugin?
> Something that checks the license and possibly authorship/copyright is
> probably important.  Beyond that, I'm not sure how useful checkstyle
> would be.
>
> In NetBeans, every time I create a new class I use a template that lets
> me choose the license.  Surely other IDE's have a way to do this?
>>
>> With regards to the actual style my first thought was to base it on
>> WildFly code style (we do build on top of it after all). However, they
>> do not have one for IntelliJ, which makes it a no go IMO. Further I
>> don't particularly want to craft one (and try to get configs for
>> IntelliJ match Eclipse, which also passes the checkstyle). So do
>> anyone have suggestions of other projects we can borrow from?
>>
>> If we're going to incorporate a code style and re-format the current
>> code case now is a very good time.
>>
>>
>> _______________________________________________
>> keycloak-dev mailing list
>> keycloak-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>
>
>
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>



More information about the keycloak-dev mailing list