We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Rubocop incorrectly detects a case of Style/RedundantSelf in the following example:
Style/RedundantSelf
def foo bar = self.bar if self.bar bar end
Should not falsely detect Style/RedundantSelf in the provided example.
When running with rubocop -a it "fixes" it to the following:
rubocop -a
def foo bar = self.bar if bar bar end
This is incorrect, as the value of bar in this case will always be nil regardless of self.bar
bar
nil
self.bar
For /private/tmp/rubocop: Default configuration from /Users/vitaly/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-1.16.0/config/default.yml Inspecting 1 file Scanning /private/tmp/rubocop/bar.rb C Offenses: bar.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment. def foo ^ bar.rb:2:21: C: [Corrected] Style/RedundantSelf: Redundant self detected. bar = self.bar if self.bar ^^^^^^^^ 1 file inspected, 2 offenses detected, 1 offense corrected, 1 more offense can be corrected with `rubocop -A` Finished in 0.12974799999210518 seconds
Create a file foo.rb with the following content:
foo.rb
Run rubocop -a foo.rb
rubocop -a foo.rb
It should not remove self after if
self
if
$ rubocop -V 1.16.0 (using Parser 3.0.1.1, rubocop-ast 1.7.0, running on ruby 2.6.5 x86_64-darwin19)
The text was updated successfully, but these errors were encountered:
[Fix rubocop#9843] Fix Style/RedundantSelf to allow conditional nod…
e813667
…es to use `self` in the condition when a variable named is shadowed inside.
Merge pull request #9847 from dvandersluis/issue/9843
27cb14d
[Fix #9843] Fix `Style/RedundantSelf` to allow conditional nodes to use `self` in the condition when a variable named is shadowed inside
Successfully merging a pull request may close this issue.
Rubocop incorrectly detects a case of
Style/RedundantSelf
in the following example:Expected behavior
Should not falsely detect
Style/RedundantSelf
in the provided example.Actual behavior
When running with
rubocop -a
it "fixes" it to the following:This is incorrect, as the value of
bar
in this case will always benil
regardless ofself.bar
Steps to reproduce the problem
Create a file
foo.rb
with the following content:Run
rubocop -a foo.rb
It should not remove
self
afterif
RuboCop version
The text was updated successfully, but these errors were encountered: