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

False positive on Style/CommentedKeyword inside class_eval #4945

Closed
woodruffw opened this issue Oct 27, 2017 · 1 comment
Closed

False positive on Style/CommentedKeyword inside class_eval #4945

woodruffw opened this issue Oct 27, 2017 · 1 comment

Comments

@woodruffw
Copy link

I'm getting a false positive from the Style/CommentedKeyword cop in one of my codebases. It looks like RuboCop gets confused by the combination of a class_eval and a %[] string. Details below.


Expected behavior

No Style/CommentedKeyword warning.

Actual behavior

lib/kbsecret/record/abstract.rb:55:17: C: Style/CommentedKeyword: Do not place comments on the same line as the def keyword.
            def #{field}
                ^^^^^^^^

Steps to reproduce the problem

This is the most minimal example I could come up with:

class_eval %[
  def #{field}
    "foo"
  end
]

The actual offending code in my own codebase is here: https://github.com/kbsecret/kbsecret/blob/master/lib/kbsecret/record/abstract.rb#L53

RuboCop version

Include the output of rubocop -V. Here's an example:

$ rubocop -V
0.51.0 (using Parser 2.4.0.0, running on ruby 2.4.2 x86_64-linux-gnu)
@pocke
Copy link
Collaborator

pocke commented Oct 27, 2017

duplicated. #4886
And this problem will be fixed by #4944

@pocke pocke closed this as completed Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants