Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by nimblegorilla on Tuesday February 18, 2020 @02:04PM
(#22359134)
In my opinion the rules about requiring or forbidding parentheses are fairly arbitrary.
Sometimes it's really nice to fit three panes of code on a single laptop screen. Long lines can also indicate a code smell. It's ironic that one of the first things most teams change is the 80 character line length.
Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by sbaha88 on Tuesday February 18, 2020 @08:25PM
(#22362254)
I remember having a bug because Rubocop changed 'and' to '&&'. I don't think that a linter should have a rule that breaks the language rules
Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by joeframbach on Tuesday February 18, 2020 @08:59PM
(#22362448)
Yup. `conditional or return fallbackValue`. Rubocop desperately wants to change this to `conditional || return fallbackValue` but that's just.... not a thing.
Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by 22c on Tuesday February 18, 2020 @06:22PM
(#22361503)
Not every rule has a reason, some of it is just "because style guide" and if you try to look up the rationale there, you'll find none.
Classic example is Perl style %w(literal arrays) vs ['traditional', 'arrays'].
> Prefer `%w` to the literal array syntax when you need an array of strings
Which was introduced[1] into the style guide nearly 9 years ago with practically no reasoning. Prefer `%w` because why exactly?
[1] https://github.com/rubocop-hq/ruby-style-guide/commit/b27eff...
Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by hirundo on Tuesday February 18, 2020 @09:48PM
(#22362666)
I prefer the brackets to parens because it makes it more clear at a glance that the result is an array.
Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by block_dagger on Thursday February 20, 2020 @06:44PM
(#22379683)
Shorter. Different code coloring. I prefer %w where possible with or without Rubocop.
Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by chrisseaton on Tuesday February 18, 2020 @04:01PM
(#22360362)
Some rules break Ruby semantics - if you apply their 'rule' you get a program that does something different! I think that's an unreasonable rule.
Re:RuboCop 0.80: Ruby static code analyzer and code formatter
by whalesalad on Wednesday February 19, 2020 @12:44AM
(#22363324)
FWIW, I was just sharing this with someone the other day when discussing the same issue https://gist.github.com/whalesalad/820810f2e969eef816402241a...
Our team has overridden about a dozen rules (we bumped up line length and class length), but I find most of the default rules are fine.
Out of curiosity, what rules are unreasonable to you?