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

Style/SymbolProc auto-correct breaking syntax #2588

Closed
NobodysNightmare opened this issue Jan 6, 2016 · 5 comments
Closed

Style/SymbolProc auto-correct breaking syntax #2588

NobodysNightmare opened this issue Jan 6, 2016 · 5 comments

Comments

@NobodysNightmare
Copy link
Contributor

Reproduction

$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
$ rubocop -v
0.35.1

Using the following test file (dubbed rubocop_test.rb):

def mail(to:, subject:)
  yield to
end

mail(
      to: 'foo',
      subject: 'bar',
    ) { |format| format.text }

Run rubocop -a rubocop_test.rb

Expected

A valid ruby file, with fewer offenes.

Actual

The syntax gets messed up by the Style/SymbolProc rule:

def mail(to:, subject:)
  yield to
end

mail(
  to: 'foo',
  subject: 'bar', &:text,
)

The extra comma after the &:text parameter is breaking the syntax.

@alexdowad
Copy link
Contributor

The extra comma after the &:text parameter is breaking the syntax.

The extra comma is actually the one which was already there, after subject: 'bar'.

Thinking about how to resolve this...

@alexdowad
Copy link
Contributor

I have an idea.

@NobodysNightmare
Copy link
Contributor Author

Wow...

I totally copy and pasted that example out of production code and didn't notice the comma after subject: 'bar'...
Now I am wondering why it was valid before, but I guess ruby is forgiving at times...

@alexdowad
Copy link
Contributor

Just pushing a fix to my open PR.

@NobodysNightmare
Copy link
Contributor Author

@alexdowad Wow, that is what I call a quick response!

Thanks for your efforts 👍 (and bonus points for the title of your PR ^^)

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