Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrailingComma* styles don't correctly identify multiline literals #2742

Closed
fj opened this issue Jan 29, 2016 · 1 comment
Closed

TrailingComma* styles don't correctly identify multiline literals #2742

fj opened this issue Jan 29, 2016 · 1 comment

Comments

@fj
Copy link

fj commented Jan 29, 2016

# version
 ψ rubocop -V
0.36.0 (using Parser 2.3.0.2, running on ruby 2.3.0 x86_64-linux)
# .rubocop.yml
Style/TrailingCommaInArguments:
  EnforcedStyleForMultiline: no_comma

Style/TrailingCommaInLiteral:
  EnforcedStyleForMultiline: consistent_comma
# foo.rb
    let(:available_channels) { [{name: channel_name, api_identifier: channel_api_id}] }

Rubocop complains:

foo.rb:1:33: C: Style/TrailingCommaInLiteral: Put a comma after the last item of a multiline array.                                    
    let(:available_channels) { [{name: channel_name, api_identifier: channel_api_id}] }
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

but this is not a multiline array; in fact, there's only one line in the whole file so it can't be a multiline array by definition!

@Annih
Copy link
Contributor

Annih commented Feb 1, 2016

Hello,

I think I found the root cause of this issue, and proposed a patch in #2757
After investigation it seems that the issue was only for single element array/hash, do you confirm @fj ?

Regards.

@bbatsov bbatsov closed this as completed in 5c5ccdb Feb 3, 2016
bbatsov added a commit that referenced this issue Feb 3, 2016
…arrays

[Fix #2742] Fix TrailingComma cop for single element arrays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants