Actions
Bug #14674
closedNew mismatched indentations warnings?
Bug #14674:
New mismatched indentations warnings?
Actions
Added by marcandre (Marc-Andre Lafortune) over 8 years ago. Updated over 8 years ago.
I think in the long run it would be nice if ruby hackers have more
control over non-error messages (e. g. warnings).
Some may prefer ruby providing cues for a more consistent code
layout but others may not necessarily care that much. In both
situations it would be nice to be able to decide on the verbosity
level of warnings.
It was intentional, but mismatched with your style?
I strongly believe that it is not Ruby's parser job to warn us about styling, especially if there's no strong reason to suspect that it's a programmer error.
I realize rubocop is not official or part of MRI, but it has the required qualities to do this:
rubocop can even autocorrect according to these desired specs. Ruby MRI has none of these features!
Note that rubocop already supports Layout/CaseIndentation, can issue warning, error, or ignore it. It supports two different alignment styles, and supports any desired indent.
In short: warnings should be kept to a strict minimum in MRI, and enforcing a style for case/when is a terrible use of a warning.
Would you consider reverting this, or asking Matz?
I agree with @marcandre (Marc-Andre Lafortune). I used to prefer "indented when" style once, and still think it is pretty acceptable.
When Ruby has introduced interpreter warnings about mismatched indentation, I thought it is a good thing, allowing to catch obvious typos like this:
def foo
bar.each do
end # forgot to close do/end of "each", hard to spot after a large methods
#...
# Without that warning, the interpreter error about missing "end" at the very end of the file,
# far from the actual point of error
But for being useful this way, the interpreter should report only absolutely obvious and unambiguous typos, not "non-preferred style". Ruby is too mature to introduce hardcoded style preferences, I believe.
Applied in changeset trunk|r63141.
parse.y: when indent
when than case.