cityindex-attic / logsearch

[unmaintained] A development environment for ELK
Apache License 2.0
24 stars 8 forks source link

Ruby Coding Standard #333

Closed dpb587 closed 10 years ago

dpb587 commented 10 years ago

Several of our ruby files differ in how many spaces we use for tabs. I'd like to standardize, but I'm not sure what the team preference is.

sopel commented 10 years ago

Good question - we should shortly discuss this via @ryanholder's resp. https://github.com/cityindex/team-standards/issues/1 still, but from previous discussions I'm pretty sure that most of the team a) prefer tabs over spaces in general, but b) agree on complying with the resp. platform's established standard (which strangely is spaces over tabs more often than not). So my vote here would be to follow whatever the Ruby coding standard is (if any, but I'd hope so).

ryanholder commented 10 years ago

@dpb587 We did start a conversation around this in the standards repo that @sopel is running, however myself and @mrdavidlaing agreed yesterday to using a proper tab character (equivalent to 4 spaces) for all files unless a specific file, like yaml, will not work with the tab character.

We agreed on this for the Logsearch Environment Diagram project yesterday.

dpb587 commented 10 years ago

I'm not sure if those were more informative comments or directives because they seem to counter each other - I thought the Ruby community was a two space indent type of place. I'm not a Ruby person to necessarily know and I don't care to argue either way here... I just want to be told what to do :)

mrdavidlaing commented 10 years ago

I'm seeing an increasing number of Ruby projects use the Rubocop code style analyser to "fail" builds which don't adhere to code standards.

This defaults to enforcing the "Ruby Style Guide", which favours

Use two spaces per indentation level (aka soft tabs). No hard tabs. See - https://github.com/bbatsov/ruby-style-guide#source-code-layout

Thus, for Ruby projects I propose:

  1. Use two spaces per indentation level
  2. [eventually] Integrate Rubocop into our builds to enforce this
sopel commented 10 years ago

Just to clarify this: We can/should shortly address the topic from a more generic PoV via https://github.com/cityindex/team-standards/issues/1 still occasionally (though the outcome seems similarly clear already), but for the question/task at hand, the majority prefers to follow the Ruby Style Guide as outlined by @mrdavidlaing.