You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Wido den Hollander <wi...@widodh.nl> on 2012/06/22 18:37:34 UTC

Coding conventions, spaces and tabs

Hi,

While working on CloudStack I noticed that a lot of files still use tabs 
instead of spaces.

I've been working on the agent mainly and there it seems bad.

The coding convention [0] says:

"Must indent with space not tabs. Indentation = 4 spaces"

Now, I'm sure this is legacy, but would anybody vote against fixing this?

A simple find + sed could fix a lot:

$ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;

I would want to try with the agent first and see how that works out, 
later on we can fix other components like api, core and server.

Objections? Suggestions?

Wido

[0]: 
http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions

Re: Coding conventions, spaces and tabs

Posted by Wido den Hollander <wi...@widodh.nl>.

On 06/22/2012 08:03 PM, David Nalley wrote:
> On Fri, Jun 22, 2012 at 12:45 PM, David Nalley<da...@gnsa.us>  wrote:
>> On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander<wi...@widodh.nl>  wrote:
>>> Hi,
>>>
>>> While working on CloudStack I noticed that a lot of files still use tabs
>>> instead of spaces.
>>>
>>> I've been working on the agent mainly and there it seems bad.
>>>
>>> The coding convention [0] says:
>>>
>>> "Must indent with space not tabs. Indentation = 4 spaces"
>>>
>>> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>>>
>>> A simple find + sed could fix a lot:
>>>
>>> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>>>
>>> I would want to try with the agent first and see how that works out, later
>>> on we can fix other components like api, core and server.
>>>
>>> Objections? Suggestions?
>>>
>>> Wido
>>>
>>> [0]:
>>> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions
>>
>> A couple of comments - (and I don't know what infra's take on
>> pre-commit hooks is, they may be verboten)
>>
>> Before this work started I'd like to see a pre-commit hook that
>> rejects commits with tabs, so that we stop the problem. (I also want
>> to see testing for line endings) Line endings and spaces are easy
>> places to start from a coding convention requirement phase, and we can
>> continue to build that up.
>>
>> Aside from that, I'd love to see this done.
>>
>> --David
>
> OK, update - I talked with joes4 and danielsh in #asfinfra - and they
> have a core set of hooks (for instance post-commit mail) and they are
> worried about inefficiency, and claim that n number of hooks per
> project is unsustainable/unmaintainable long term for hundreds of
> repos, and that's a valid reasoning, so perhaps we need to make this a
> jenkins job (and this looks like a great place to start our CI efforts
> on ASF infrastructure). Does that seem reasonable to accomplish Wido?
>

I'm not familiar with Jenkins at all, so I'm not able to give a good 
answer on that.

I however did just pushed a commit where the agent directory is set 
straight.

Since most of the work is currently done in the core, server, api and ui 
I thought the agent was a safe place to start with.

But when commit hooks are not possible we should look for another 
solution. Keeping the code tidy is important imho.

Wido

> --David

Re: Coding conventions, spaces and tabs

Posted by Robert Schweikert <rj...@suse.com>.
On 06/22/2012 02:03 PM, David Nalley wrote:
> On Fri, Jun 22, 2012 at 12:45 PM, David Nalley <da...@gnsa.us> wrote:
>> On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander <wi...@widodh.nl> wrote:
>>> Hi,
>>>
>>> While working on CloudStack I noticed that a lot of files still use tabs
>>> instead of spaces.
>>>
>>> I've been working on the agent mainly and there it seems bad.
>>>
>>> The coding convention [0] says:
>>>
>>> "Must indent with space not tabs. Indentation = 4 spaces"
>>>
>>> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>>>
>>> A simple find + sed could fix a lot:
>>>
>>> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>>>
>>> I would want to try with the agent first and see how that works out, later
>>> on we can fix other components like api, core and server.
>>>
>>> Objections? Suggestions?
>>>
>>> Wido
>>>
>>> [0]:
>>> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions
>>
>> A couple of comments - (and I don't know what infra's take on
>> pre-commit hooks is, they may be verboten)
>>
>> Before this work started I'd like to see a pre-commit hook that
>> rejects commits with tabs, so that we stop the problem. (I also want
>> to see testing for line endings) Line endings and spaces are easy
>> places to start from a coding convention requirement phase, and we can
>> continue to build that up.
>>
>> Aside from that, I'd love to see this done.
>>
>> --David
>
> OK, update - I talked with joes4 and danielsh in #asfinfra - and they
> have a core set of hooks (for instance post-commit mail) and they are
> worried about inefficiency, and claim that n number of hooks per
> project is unsustainable/unmaintainable long term for hundreds of
> repos, and that's a valid reasoning, so perhaps we need to make this a
> jenkins job (and this looks like a great place to start our CI efforts
> on ASF infrastructure).

We could have commit hooks and could depend on convention.

On another project I am involved with we have a hidden directory, 
.git-hooks, as part of the source tree. This directory contains the 
project's hook scripts. Contributors are expected to have a link from 
.git/hooks to .git-hooks such that the checks are run as expected.

Yes, these leaves the possibility for something to get missed, but as we 
do not have an incredible abundance of committers, and possibly should 
never get to that point, it appears reasonable to ask every committer to 
set up this link in the source tree they work with.

Later,
Robert



-- 
Robert Schweikert                           MAY THE SOURCE BE WITH YOU
SUSE-IBM Software Integration Center                   LINUX
Tech Lead
rjschwei@suse.com
rschweik@ca.ibm.com
781-464-8147



Re: Coding conventions, spaces and tabs

Posted by David Nalley <da...@gnsa.us>.
On Fri, Jun 22, 2012 at 12:45 PM, David Nalley <da...@gnsa.us> wrote:
> On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander <wi...@widodh.nl> wrote:
>> Hi,
>>
>> While working on CloudStack I noticed that a lot of files still use tabs
>> instead of spaces.
>>
>> I've been working on the agent mainly and there it seems bad.
>>
>> The coding convention [0] says:
>>
>> "Must indent with space not tabs. Indentation = 4 spaces"
>>
>> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>>
>> A simple find + sed could fix a lot:
>>
>> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>>
>> I would want to try with the agent first and see how that works out, later
>> on we can fix other components like api, core and server.
>>
>> Objections? Suggestions?
>>
>> Wido
>>
>> [0]:
>> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions
>
> A couple of comments - (and I don't know what infra's take on
> pre-commit hooks is, they may be verboten)
>
> Before this work started I'd like to see a pre-commit hook that
> rejects commits with tabs, so that we stop the problem. (I also want
> to see testing for line endings) Line endings and spaces are easy
> places to start from a coding convention requirement phase, and we can
> continue to build that up.
>
> Aside from that, I'd love to see this done.
>
> --David

OK, update - I talked with joes4 and danielsh in #asfinfra - and they
have a core set of hooks (for instance post-commit mail) and they are
worried about inefficiency, and claim that n number of hooks per
project is unsustainable/unmaintainable long term for hundreds of
repos, and that's a valid reasoning, so perhaps we need to make this a
jenkins job (and this looks like a great place to start our CI efforts
on ASF infrastructure). Does that seem reasonable to accomplish Wido?

--David

Re: Coding conventions, spaces and tabs

Posted by John Kinsella <jl...@stratosec.co>.
+1
On Jun 22, 2012, at 9:45 AM, David Nalley wrote:

> On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander <wi...@widodh.nl> wrote:
>> Hi,
>> 
>> While working on CloudStack I noticed that a lot of files still use tabs
>> instead of spaces.
>> 
>> I've been working on the agent mainly and there it seems bad.
>> 
>> The coding convention [0] says:
>> 
>> "Must indent with space not tabs. Indentation = 4 spaces"
>> 
>> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>> 
>> A simple find + sed could fix a lot:
>> 
>> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>> 
>> I would want to try with the agent first and see how that works out, later
>> on we can fix other components like api, core and server.
>> 
>> Objections? Suggestions?
>> 
>> Wido
>> 
>> [0]:
>> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions
> 
> A couple of comments - (and I don't know what infra's take on
> pre-commit hooks is, they may be verboten)
> 
> Before this work started I'd like to see a pre-commit hook that
> rejects commits with tabs, so that we stop the problem. (I also want
> to see testing for line endings) Line endings and spaces are easy
> places to start from a coding convention requirement phase, and we can
> continue to build that up.
> 
> Aside from that, I'd love to see this done.
> 
> --David

Stratosec - Secure Infrastructure as a Service
o: 415.315.9385
@johnlkinsella


Re: Coding conventions, spaces and tabs

Posted by Hugo Trippaers <HT...@schubergphilis.com>.
Easy enough to setup Jenkins to catch this as well. I don't know about the reviewboard setup, but if it's linked to jenkins we can spot this before accepting the patch.

Maybe also add the note about the git crlf settings to the developer wiki in an easy to find spot?

Cheers,

Hugo 

Sent from my iPhone

On 22 jun. 2012, at 22:23, "Sheng Yang" <sh...@yasker.org> wrote:

> On Fri, Jun 22, 2012 at 9:45 AM, David Nalley <da...@gnsa.us> wrote:
>> On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander <wi...@widodh.nl> wrote:
>>> Hi,
>>> 
>>> While working on CloudStack I noticed that a lot of files still use tabs
>>> instead of spaces.
>>> 
>>> I've been working on the agent mainly and there it seems bad.
>>> 
>>> The coding convention [0] says:
>>> 
>>> "Must indent with space not tabs. Indentation = 4 spaces"
>>> 
>>> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>>> 
>>> A simple find + sed could fix a lot:
>>> 
>>> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>>> 
>>> I would want to try with the agent first and see how that works out, later
>>> on we can fix other components like api, core and server.
>>> 
>>> Objections? Suggestions?
>>> 
>>> Wido
>>> 
>>> [0]:
>>> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions
>> 
>> A couple of comments - (and I don't know what infra's take on
>> pre-commit hooks is, they may be verboten)
>> 
>> Before this work started I'd like to see a pre-commit hook that
>> rejects commits with tabs, so that we stop the problem. (I also want
>> to see testing for line endings) Line endings and spaces are easy
>> places to start from a coding convention requirement phase, and we can
>> continue to build that up.
>> 
>> Aside from that, I'd love to see this done.
> 
> +1.
> 
> Can't wait to see it.
> 
> --Sheng
>> 
>> --David

Re: Coding conventions, spaces and tabs

Posted by Sheng Yang <sh...@yasker.org>.
On Fri, Jun 22, 2012 at 9:45 AM, David Nalley <da...@gnsa.us> wrote:
> On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander <wi...@widodh.nl> wrote:
>> Hi,
>>
>> While working on CloudStack I noticed that a lot of files still use tabs
>> instead of spaces.
>>
>> I've been working on the agent mainly and there it seems bad.
>>
>> The coding convention [0] says:
>>
>> "Must indent with space not tabs. Indentation = 4 spaces"
>>
>> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>>
>> A simple find + sed could fix a lot:
>>
>> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>>
>> I would want to try with the agent first and see how that works out, later
>> on we can fix other components like api, core and server.
>>
>> Objections? Suggestions?
>>
>> Wido
>>
>> [0]:
>> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions
>
> A couple of comments - (and I don't know what infra's take on
> pre-commit hooks is, they may be verboten)
>
> Before this work started I'd like to see a pre-commit hook that
> rejects commits with tabs, so that we stop the problem. (I also want
> to see testing for line endings) Line endings and spaces are easy
> places to start from a coding convention requirement phase, and we can
> continue to build that up.
>
> Aside from that, I'd love to see this done.

+1.

Can't wait to see it.

--Sheng
>
> --David

RE: Coding conventions, spaces and tabs

Posted by Vijayendra Bhamidipati <vi...@citrix.com>.

-----Original Message-----
From: David Nalley [mailto:david@gnsa.us] 
Sent: Friday, June 22, 2012 9:45 AM
To: cloudstack-dev@incubator.apache.org
Subject: Re: Coding conventions, spaces and tabs

On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander <wi...@widodh.nl> wrote:
> Hi,
>
> While working on CloudStack I noticed that a lot of files still use tabs
> instead of spaces.
>
> I've been working on the agent mainly and there it seems bad.
>
> The coding convention [0] says:
>
> "Must indent with space not tabs. Indentation = 4 spaces"
>
> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>
> A simple find + sed could fix a lot:
>
> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>
> I would want to try with the agent first and see how that works out, later
> on we can fix other components like api, core and server.
>
> Objections? Suggestions?
>
> Wido
>
> [0]:
> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions

A couple of comments - (and I don't know what infra's take on
pre-commit hooks is, they may be verboten)

Before this work started I'd like to see a pre-commit hook that
rejects commits with tabs, so that we stop the problem. (I also want
to see testing for line endings) Line endings and spaces are easy
places to start from a coding convention requirement phase, and we can
continue to build that up.

Aside from that, I'd love to see this done.

--David




>> Sheng Yang sent me this useful link (that you put up) yesterday for those using eclipse to work with the cloudstack codebase : http://docs.cloudstack.org/Knowledge_Base/How_to_set_up_a_CloudStack_development_environment/Eclipse_profiles


Regards,
Vijay

Re: Coding conventions, spaces and tabs

Posted by David Nalley <da...@gnsa.us>.
On Fri, Jun 22, 2012 at 12:37 PM, Wido den Hollander <wi...@widodh.nl> wrote:
> Hi,
>
> While working on CloudStack I noticed that a lot of files still use tabs
> instead of spaces.
>
> I've been working on the agent mainly and there it seems bad.
>
> The coding convention [0] says:
>
> "Must indent with space not tabs. Indentation = 4 spaces"
>
> Now, I'm sure this is legacy, but would anybody vote against fixing this?
>
> A simple find + sed could fix a lot:
>
> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
>
> I would want to try with the agent first and see how that works out, later
> on we can fix other components like api, core and server.
>
> Objections? Suggestions?
>
> Wido
>
> [0]:
> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Coding_Conventions

A couple of comments - (and I don't know what infra's take on
pre-commit hooks is, they may be verboten)

Before this work started I'd like to see a pre-commit hook that
rejects commits with tabs, so that we stop the problem. (I also want
to see testing for line endings) Line endings and spaces are easy
places to start from a coding convention requirement phase, and we can
continue to build that up.

Aside from that, I'd love to see this done.

--David

RE: Coding conventions, spaces and tabs

Posted by Alex Huang <Al...@citrix.com>.

> -----Original Message-----
> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> Sent: Friday, June 22, 2012 1:57 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: Coding conventions, spaces and tabs
> 
> An annoying thing is Eclipse doesn't have a global setting for all instances, its
> setting is per workspace. I wish I were wrong.
> As I have multiple workspaces for various branches, it's easy to forget to
> configure the workspace whenever I create a new one.
> 
I export my eclipse settings and import for each workspace.

It is very easy to forget that eclipse by default uses tabs.  No idea why.  Almost every coding convention out there says to use space and the mix is horrible to look at on a web browser.

--Alex

RE: Coding conventions, spaces and tabs

Posted by Frank Zhang <Fr...@citrix.com>.
An annoying thing is Eclipse doesn't have a global setting for all instances, its setting is per workspace. I wish I were wrong.
As I have multiple workspaces for various branches, it's easy to forget to configure the workspace whenever I create a new one.

> -----Original Message-----
> From: Deepak Garg [mailto:deepak.garg@citrix.com]
> Sent: Friday, June 22, 2012 12:52 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: Coding conventions, spaces and tabs
> 
> +1
> 
> 
> In Eclipse it is easy to configure the editor to replace 'tabs' with 'spaces' and
> also to kill the trailing whitespaces:
> 
> To remove the trailing whitespaces on save:
> 
> Preferences -> Java -> Editor -> Save Actions -> Configure Project Specific
> settings -> (choose project) -> Configure -> Choose "Remove Trailing
> WhiteSpace"
> 
> 
> Thanks,
> Deepak
> 
> 
> -----Original Message-----
> From: Edison Su [mailto:Edison.su@citrix.com]
> Sent: Friday, June 22, 2012 10:56 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: RE: Coding conventions, spaces and tabs
> 
> +1
> 
> > -----Original Message-----
> > From: Wido den Hollander [mailto:wido@widodh.nl]
> > Sent: Friday, June 22, 2012 9:38 AM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: Coding conventions, spaces and tabs
> >
> > Hi,
> >
> > While working on CloudStack I noticed that a lot of files still use
> > tabs instead of spaces.
> >
> > I've been working on the agent mainly and there it seems bad.
> >
> > The coding convention [0] says:
> >
> > "Must indent with space not tabs. Indentation = 4 spaces"
> >
> > Now, I'm sure this is legacy, but would anybody vote against fixing
> > this?
> >
> > A simple find + sed could fix a lot:
> >
> > $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
> >
> > I would want to try with the agent first and see how that works out,
> > later on we can fix other components like api, core and server.
> >
> > Objections? Suggestions?
> >
> > Wido
> >
> > [0]:
> >
> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/
> C
> > o
> > ding_Conventions

RE: Coding conventions, spaces and tabs

Posted by Rajesh Battala <ra...@citrix.com>.
How about this tool http://checkstyle.sourceforge.net/ 
This tool can be used as plugin in many editors. 

> -----Original Message-----
> From: Sheng Yang [mailto:sheng@yasker.org]
> Sent: Tuesday, June 26, 2012 12:07 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: Coding conventions, spaces and tabs
> 
> On Sat, Jun 23, 2012 at 8:45 AM, Deepak Garg <de...@citrix.com>
> wrote:
> >
> >
> > -----Original Message-----
> > From: David Nalley [mailto:david@gnsa.us]
> > Sent: Saturday, June 23, 2012 1:27 AM
> > To: cloudstack-dev@incubator.apache.org
> > Subject: Re: Coding conventions, spaces and tabs
> >
> > On Fri, Jun 22, 2012 at 3:51 PM, Deepak Garg <de...@citrix.com>
> wrote:
> >> +1
> >>
> >>
> >> In Eclipse it is easy to configure the editor to replace 'tabs' with 'spaces'
> and also to kill the trailing whitespaces:
> >>
> >> To remove the trailing whitespaces on save:
> >>
> >> Preferences -> Java -> Editor -> Save Actions -> Configure Project Specific
> settings -> (choose project) -> Configure -> Choose "Remove Trailing
> WhiteSpace"
> >>
> >>
> >
> >
> >>So not to be argumentative, but:
> >
> >>It may be easy, but that doesn't mean people will do 'The Right
> >>Thing', hence why there are so many coding convention problems in our
> >>codebase.
> >
> >>--David
> >
> >
> > One way to solve this problem is to have a script or may be something in
> unit tests which people can run locally on the entire codebase before
> pushing the code to the community. It can throw errors and point to such
> violations.
> > As developers have varied choices of their editors, so this will be a ground
> check for them before they push the code.
> > This is similar to how pep8 checks were used in Openstack unit test bundle.
> >
> 
> This is very useful, though it would require quite some time to develop it.
> 
> Linux kernel community also has a set of very good tools to help. For
> example everyone need to run checkpatch.pl before submit the patch.
> But that one is a ~4000 line script.
> 
> I think we need a volunteer for this? Or is there any tool we can borrow?
> 
> --Sheng
> >
> > Deepak
> >

Re: Coding conventions, spaces and tabs

Posted by Sheng Yang <sh...@yasker.org>.
On Sat, Jun 23, 2012 at 8:45 AM, Deepak Garg <de...@citrix.com> wrote:
>
>
> -----Original Message-----
> From: David Nalley [mailto:david@gnsa.us]
> Sent: Saturday, June 23, 2012 1:27 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Re: Coding conventions, spaces and tabs
>
> On Fri, Jun 22, 2012 at 3:51 PM, Deepak Garg <de...@citrix.com> wrote:
>> +1
>>
>>
>> In Eclipse it is easy to configure the editor to replace 'tabs' with 'spaces' and also to kill the trailing whitespaces:
>>
>> To remove the trailing whitespaces on save:
>>
>> Preferences -> Java -> Editor -> Save Actions -> Configure Project Specific settings -> (choose project) -> Configure -> Choose "Remove Trailing WhiteSpace"
>>
>>
>
>
>>So not to be argumentative, but:
>
>>It may be easy, but that doesn't mean people will do 'The Right
>>Thing', hence why there are so many coding convention problems in our
>>codebase.
>
>>--David
>
>
> One way to solve this problem is to have a script or may be something in unit tests which people can run locally on the entire codebase before pushing the code to the community. It can throw errors and point to such violations.
> As developers have varied choices of their editors, so this will be a ground check for them before they push the code.
> This is similar to how pep8 checks were used in Openstack unit test bundle.
>

This is very useful, though it would require quite some time to develop it.

Linux kernel community also has a set of very good tools to help. For
example everyone need to run checkpatch.pl before submit the patch.
But that one is a ~4000 line script.

I think we need a volunteer for this? Or is there any tool we can borrow?

--Sheng
>
> Deepak
>

RE: Coding conventions, spaces and tabs

Posted by Deepak Garg <de...@citrix.com>.

-----Original Message-----
From: David Nalley [mailto:david@gnsa.us] 
Sent: Saturday, June 23, 2012 1:27 AM
To: cloudstack-dev@incubator.apache.org
Subject: Re: Coding conventions, spaces and tabs

On Fri, Jun 22, 2012 at 3:51 PM, Deepak Garg <de...@citrix.com> wrote:
> +1
>
>
> In Eclipse it is easy to configure the editor to replace 'tabs' with 'spaces' and also to kill the trailing whitespaces:
>
> To remove the trailing whitespaces on save:
>
> Preferences -> Java -> Editor -> Save Actions -> Configure Project Specific settings -> (choose project) -> Configure -> Choose "Remove Trailing WhiteSpace"
>
>


>So not to be argumentative, but:

>It may be easy, but that doesn't mean people will do 'The Right
>Thing', hence why there are so many coding convention problems in our
>codebase.

>--David


One way to solve this problem is to have a script or may be something in unit tests which people can run locally on the entire codebase before pushing the code to the community. It can throw errors and point to such violations. 
As developers have varied choices of their editors, so this will be a ground check for them before they push the code.
This is similar to how pep8 checks were used in Openstack unit test bundle.


Deepak


Re: Coding conventions, spaces and tabs

Posted by David Nalley <da...@gnsa.us>.
On Fri, Jun 22, 2012 at 3:51 PM, Deepak Garg <de...@citrix.com> wrote:
> +1
>
>
> In Eclipse it is easy to configure the editor to replace 'tabs' with 'spaces' and also to kill the trailing whitespaces:
>
> To remove the trailing whitespaces on save:
>
> Preferences -> Java -> Editor -> Save Actions -> Configure Project Specific settings -> (choose project) -> Configure -> Choose "Remove Trailing WhiteSpace"
>
>


So not to be argumentative, but:

It may be easy, but that doesn't mean people will do 'The Right
Thing', hence why there are so many coding convention problems in our
codebase.

--David

RE: Coding conventions, spaces and tabs

Posted by Deepak Garg <de...@citrix.com>.
+1


In Eclipse it is easy to configure the editor to replace 'tabs' with 'spaces' and also to kill the trailing whitespaces:

To remove the trailing whitespaces on save:

Preferences -> Java -> Editor -> Save Actions -> Configure Project Specific settings -> (choose project) -> Configure -> Choose "Remove Trailing WhiteSpace"


Thanks,
Deepak


-----Original Message-----
From: Edison Su [mailto:Edison.su@citrix.com] 
Sent: Friday, June 22, 2012 10:56 PM
To: cloudstack-dev@incubator.apache.org
Subject: RE: Coding conventions, spaces and tabs

+1

> -----Original Message-----
> From: Wido den Hollander [mailto:wido@widodh.nl]
> Sent: Friday, June 22, 2012 9:38 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Coding conventions, spaces and tabs
> 
> Hi,
> 
> While working on CloudStack I noticed that a lot of files still use
> tabs
> instead of spaces.
> 
> I've been working on the agent mainly and there it seems bad.
> 
> The coding convention [0] says:
> 
> "Must indent with space not tabs. Indentation = 4 spaces"
> 
> Now, I'm sure this is legacy, but would anybody vote against fixing
> this?
> 
> A simple find + sed could fix a lot:
> 
> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
> 
> I would want to try with the agent first and see how that works out,
> later on we can fix other components like api, core and server.
> 
> Objections? Suggestions?
> 
> Wido
> 
> [0]:
> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Co
> ding_Conventions

RE: Coding conventions, spaces and tabs

Posted by Edison Su <Ed...@citrix.com>.
+1

> -----Original Message-----
> From: Wido den Hollander [mailto:wido@widodh.nl]
> Sent: Friday, June 22, 2012 9:38 AM
> To: cloudstack-dev@incubator.apache.org
> Subject: Coding conventions, spaces and tabs
> 
> Hi,
> 
> While working on CloudStack I noticed that a lot of files still use
> tabs
> instead of spaces.
> 
> I've been working on the agent mainly and there it seems bad.
> 
> The coding convention [0] says:
> 
> "Must indent with space not tabs. Indentation = 4 spaces"
> 
> Now, I'm sure this is legacy, but would anybody vote against fixing
> this?
> 
> A simple find + sed could fix a lot:
> 
> $ find -name '*.java' -exec sed -i --posix -e 's/\t/    /g' {} \;
> 
> I would want to try with the agent first and see how that works out,
> later on we can fix other components like api, core and server.
> 
> Objections? Suggestions?
> 
> Wido
> 
> [0]:
> http://docs.cloudstack.org/CloudStack_Documentation/Design_Documents/Co
> ding_Conventions