Layout/ArgumentAlignment - False positive?
wynksaiddestroy opened this issue · 2 comments
I have cobbled together the following example:
.regular.html{
'data-very-long-so-this-cant-be-on-the-line-above': 'something',
'data-it-needs-at-least-two-attributes-to-fail': 'something'
}
According to the Reference this should be possible, but unfortunately running haml-lint
I get the following errors:
test.haml:2 [W] RuboCop: Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
test.haml:2 [W] RuboCop: Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
Is this a bug? Is my example considered bad style? Is there a way around without putting the second line behind the first one?
With just one data attribute it works just fine:
.regular.html{
'data-very-long-so-this-cant-be-on-the-line-above': 'something'
}
I do know that I could just do
.regular.html{ 'data-very-long-so-this-cant-be-on-the-line-above': 'something',
'data-it-needs-at-least-two-attributes': 'something' }
but I want to enforce the LineLength cop, so this way isn't feasible in my case.
Hello, yeah, there is a bit of a problem with how whitespace around tag attributes was being handled.
In short, the initial newlines were being lost. So
.regular.html{
'data-very-long-so-this-cant-be-on-the-line-above': 'something',
'data-it-needs-at-least-two-attributes-to-fail': 'something'
}
Became this ruby code (for processing with RuboCop):
WWWWWW('data-very-long-so-this-cant-be-on-the-line-above': 'something',
'data-it-needs-at-least-two-attributes-to-fail': 'something')
I made #487 to solve this. Now the generated code would be:
WWWWWW(
'data-very-long-so-this-cant-be-on-the-line-above': 'something',
'data-it-needs-at-least-two-attributes-to-fail': 'something'
)
Which does look like an "exact" replica of the layout in the haml.
Thank you very very much for the crazy fast fix, @MaxLap 😊