BuildCraft|Core

BuildCraft|Core

7M Downloads

Common coding standard

SpaceToad opened this issue · 25 comments

commented

Following last contributions, it becomes apparent that we need some kind of a common coding standard, and a way to share it. @Prototik suggested to look at EditorConfig (http://editorconfig.org/), but there doesn't seem to be an Eclipse plug-in to it. Any suggestion as to what formalism to share is welcome, knowing that we need to support at least Eclipse and probably IntellijIDEA.

commented

I Suggest supplying a Eclipse formatter, as IntelliJ can read those, and that way formallity across all boards, this is done in quite a few dev teams, take a look at tinkers for example.

commented

As a workaround for Eclipse: we can create a external gradle task which will reformat all sources post-factum.

commented

Why not just use the oracle java standards?

commented

I've used CheckStyle in the past with relative success.

http://checkstyle.sourceforge.net
On May 1, 2014 8:30 AM, "Sergey Shatunov" [email protected] wrote:

As a workaround for Eclipse: we can create a external gradle task which
will reformat all sources post-factum.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1662#issuecomment-41920680
.

commented

@dmillerw - I was actually looking at checkstyle. At least, it supports the proper environments.
@Prototik - that would only work for people that do use gradle though. I'm personally not using it except for building final sources.
@tgame14 indeed, once the format is set, it would be good to provide default formatters for environments - in particular if no common one is to be identified.

commented

Oracle standards come preconfigured in most IDEs.

edit: Checkstyle has a config for oracle standards too.

commented

@GUIpsp we're not talking about what standard to adopt yet, but which one to adopt. I tend to lean towards something derived from Eclipse, but let's get that discussion once a first proposal is made.

commented

Personally I'd base it off of what we already have, despite it being a bit
chaotic at the moment.
On May 1, 2014 8:47 AM, "SpaceToad" [email protected] wrote:

@GUIpsp https://github.com/GUIpsp we're not talking about what standard
to adopt yet, but which one to adopt. I tend to lean towards something
derived from Eclipse, but let's get that discussion once a first proposal
is made.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1662#issuecomment-41922471
.

commented

@dmillerw agreed. I'm crafting a first style checker file for initial review.

commented

@anti344 - there seems to be lots of people using checkstyle atm, which is also something I know from a couple of years ago. Nice track record which makes me hope we can use it for some time.

commented

Maybe i'm late, but http://astyle.sourceforge.net/ ?
Like you can write whatever you like, but then run this thing, as i understand it.
And ForgeGradle uses it to set style of decompiled MC(at least it has astyle.cfg file).

commented

Ok, so there's a first proposal on https://github.com/BuildCraft/BuildCraft/blob/NextGen/guidelines/buildcraft.checkstyle. Give about 4,000 warnings and errors, which is not that bad. At least, that's a first cleanup. It's not complete, in particular it doesn't looks at indentation yet, but let me know if there's anything that you feel strongly about. I'm happy to fix these afterwards.

commented

NewlineAtEndOfFile =(

commented

I'm fond of requiring javadoc comments on all methods and classes. I also prefer compact form for blocks and conditionals.

commented

@SpaceToad Looks pretty good.

commented

@AEnterprise I'm applying this on the BuildCraft codebase. There's some tweaks here and there to make it completely reasonable. I'll close the issue when a first pass has been validated, and will publish the corresponding Eclipse preference file.

commented

is this final or not? if so could somebody explain me how it works? i might also use it to format my addon

commented

Done - boy that was a big one. Found and fixed a couple of bugs along the way. I updated a tad the coding standard, in particular removing the end of file new line as it's actually not that easy to enforce in Eclipse.

@AEnterprise, if you're coding from eclipse, you can install the Eclipse Checkstyle Plug-in and feed it with https://github.com/BuildCraft/BuildCraft/blob/NextGen/guidelines/buildcraft.checkstyle. Still from Eclipse, if you code using the preferences I checked in (https://github.com/BuildCraft/BuildCraft/blob/NextGen/guidelines/buildcraft.epf) you'll have a lot of things properly done straight out.

commented

@SpaceToad thanks, i'll try it out

commented

@SpaceToad btw, next time could you move the branches around before you link me to something? i found it on my own but your links are broken

commented

It's usually safer to link to tags than branches. Branches come and go, as do their contents. Tags will stay.

commented

Or link by hash. Pressing "y" on any file will update the link to use the hash.

commented

I've noticed one of the guideline files relying on Eclipse, but what about IntelliJ IDEA?

commented

@TXX59 install checkstyle plugin from jetstore:
screenshot from 2014-05-04 15 37 52
Then activate rules via 'Settings' menu:
screenshot from 2014-05-04 15 37 01
That's end.

commented

And you can assign styles per module.