On Tue, 2010-04-20 at 16:25 +0100, Eoghan Glynn wrote:
On Tue, 2010-04-20 at 15:14 +0100, Mark McLoughlin wrote:
> Whatever happened to 'The first rule of code style is: you
do not talk
> about code style.' ? :)
LoL. Normally I'd just go with the flow on coding style, but mixed
spaces & tabs are a bridge too far :)
> Seriously, you're a java guy and I'm not - so, you should decide on the
> coding style and write it up. If you give me the appropriate settings
> for eclipse, I'll be happy to follow it (after converting it to emacs
> settings :)
I'm just using the default Eclipse formatter with one addition:
Windows->Preferences->Java->Code Style->Formatter ... Edit
General settings->Tab policy: Spaces Only
Rename the profile and hit OK
> To put my oar in - in your PowerShellVmsResource.java a blank line
> between the methods would make me feel better.
Yep, my bad, I had some further edits to that file that I hadn't saved
before committing. The bunched together methods were just a result of
sloppy copy'n'paste, and most of that code was eventually removed in any
case to avoid duplication with the corresponding VmResource. The correct
version is now on the branch:
http://git.fedorahosted.org/git/?p=rhevm-api.git;a=commit;h=f506c92
> Also, if we can at all, it'd be nice to ban "trailing whitespace"
from
> the project from the start[1] - it doesn't seem to be easy to do in
> eclipse, so if you think it'd be too much of a pain, nevermind
Yeah, I'm not particularly fond of Eclipse's insistence on dumping
trailing spaces all over the place.
Okay, I've re-indented the code and added a HACKING file, see below
Cheers,
Mark.
== Coding Style ==
We follow standard Java coding style:
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
Four spaces are used for indentation and tabs are never used.
In Eclipse, you should go to:
Windows->Preferences->Java->Code Style->Formatter
then select the 'Java conventions' profile, click Edit, change the
profile name to 'Java conventions [no tabs]' and then in:
Indentation, General settings->Tab policy
select 'Spaces Only' and hit OK.
== On Whitespace ==
Graphic designers know that the judicious use of whitespace is
critical in good design. That goes for code legibility too. If adding
a blank line makes your code more legible, then go for it!
On the other hand, trailing whitespace is the spawn of satan. Okay,
maybe not, but it adds no value and can cause unnecessary churn and
conflicts. So, let's try and avoid it.
Set up a git pre-commit hook in your local repository to check for it:
$> mv .git/hooks/pre-commit.sample .git/hooks/pre-commit
This will not allow you to create a commit containing trailing
whitespace. You can also manually check your current changes using:
$> git diff --check
In Eclipse, you go to 'Windows->Preferences->General->Keys' and bind
'Remove Trailing Whitespace' to e.g. Alt-w. That way you can just do
Alt-w before saving a file.
== Git ==
Before committing any changes, add the following to your ~/.gitconfig:
[user]
name = Joe X. User
email = joe.user(a)example.com
Try and isolate logical changes into individual commits. You can
modify your latest commit using 'git commit --amend' and modify your
commit queue using 'git rebase -i origin/master'.