You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to know if this is a good practice add comma after first line delimiter when a heredoc use in a hash like add a parenthesis when it's use as argument in a function.
Thank you.
Example
Cookstyle warning
a={toto: 'toto',tutu: 'tutu',titi: <<~EOS Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod erat eget lorem dignissim ornare. Ut pellentesque nisi nec ipsum sagittis volutpat vel vitae lorem. EOS}
hs-157@cassiopeia> cookstyle test.rb
Inspecting 1 file
C
Offenses:
test.rb:4:3: C: [Correctable] Style/TrailingCommaInHashLiteral: Put a comma after the last item of a multiline hash.
titi: <<~EOS
^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 offense auto-correctable
Cookstyle OK
a={toto: 'toto',tutu: 'tutu',titi: <<~EOS, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod erat eget lorem dignissim ornare. Ut pellentesque nisi nec ipsum sagittis volutpat vel vitae lorem. EOS}
a={toto: 'toto',titi: <<~EOS Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod erat eget lorem dignissim ornare. Ut pellentesque nisi nec ipsum sagittis volutpat vel vitae lorem. EOS, tutu: 'tutu' }
Would that cop flag this code and suggest changing to this?
a = {
toto: 'toto',
- titi: <<~EOS+ titi: <<~EOS,
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nam euismod erat eget lorem dignissim ornare.
Ut pellentesque nisi nec ipsum sagittis volutpat vel vitae lorem.
- EOS,+ EOS
tutu: 'tutu'
}
Huhu,
I have a multi-line string and I use a heredoc in hash for a cookbook Chef. For check style, I use Cookstyle as linting tool, it raise Style/TrailingCommaInHashLiteral as warning cops.
I would like to know if this is a good practice add comma after first line delimiter when a heredoc use in a hash like add a parenthesis when it's use as argument in a function.
Thank you.
Example
Cookstyle warning
Cookstyle OK
The text was updated successfully, but these errors were encountered: