[katello-devel] Number of tabs on the next line
Petr Chalupa
pchalupa at redhat.com
Wed Aug 29 17:00:01 UTC 2012
Hi,
the convention for spaces in Ruby is:
- to indent block of code use exactly 2 spaces (if, do..end, begin..end,
...)
- for line continuation use 4 spaces, optionally you can indent more to
align the attributes
I think the optional alignment should not be forced either way. Both
makes sense.
some_func some.computaion.param1,
get.me.number.of.developers.in.katello,
:an_option => 'a value'
Is more readable than
some_func some.computaion.param1,
get.me.number.of.developers.in.katello,
:an_option => 'a value'
The normal 4spaces indentation is needed as Lukas mentioned for longer
calls.
bla.bla.bla.bla.bla.bla.bla.bla.bla.bla.bla.bla.some_func(
some.computaion.param1,
get.me.number.of.developers.in.katello,
:an_option => 'a value')
+1 I would keep both options.
+1 I would correct the bad formatting incrementally.
PS: The most feature-complete Ruby formater I've ever found is part of
RubyMine (it can also format all source files at once).
Petr
On 29.08.12 16:36, Lukas Zapletal wrote:
> Hey,
>
> I noticed we have quite mix of various indention styles in our python
> code base (and ruby too). My biggest concern is line continuation.
>
> So if I have a line like this one (should work both for Python and
> Ruby):
>
> some_func(param1,
>
> and I want to continue on the next line, various editors we use
> different indent. In my case, Vim, it's always two tabs. And since we
> agreed to expand tabs with 4 spaces in Python (and 2 spaces in Ruby),
> the result is (switch to monospaced font):
>
> Python:
>
> some_func(param1,
> param2,
> param3)
>
> Ruby:
>
> some_func(param1,
> param2,
> param3)
>
> I see several different styles, it looks like it's pretty random,
> sometimes I see the next line aligned:
>
> some_func(param1,
> param2,
> param3)
>
> I personally hate this one, cos when you have a very long line than it
> looks like
>
> bla bla bla bla bla bla bla bla bla bla bla bla bla some_func(param1,
> param2,
> param3)
>
> and you obviously cannot use longer_param2 because it wraps. Also this
> alignment does not work always (sometimes structure of the first line
> does not have params).
>
> What is your preference in this case?
>
> http://micropoll.com/t/KE6MnZPqfS
>
> Do you see any other issues with our indenting or code style that we
> should discuss?
>
More information about the katello-devel
mailing list