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 Naming/MemoizedInstanceVariableName #6710

Closed
halostatue opened this issue Jan 26, 2019 · 1 comment
Closed

False positive on Naming/MemoizedInstanceVariableName #6710

halostatue opened this issue Jan 26, 2019 · 1 comment
Assignees
Labels

Comments

@halostatue
Copy link

Received Naming/MemoizedInstanceVariableName incorrectly for methods and variables with surrounding underscores.


Expected behavior

No Naming/MemoizedInstanceVariableName warning.

Actual behavior

Received message

Naming/MemoizedInstanceVariableName: Memoized variable @__instances__ does not match method name __instances__. Use @__instances__ instead.

Steps to reproduce the problem

Run RuboCop over:

require 'set'

class Foo
  def __instances__
    @__instances__ ||= Set.new
  end
end

RuboCop version

0.63.1 (using Parser 2.5.1.0, running on ruby 2.6.0 x86_64-darwin18)

@pocke pocke added the bug label Jan 26, 2019
@pocke
Copy link
Collaborator

pocke commented Jan 26, 2019

Thank you for your reporting!

More small code to reproduce:

def _a
  @_a ||= x
end

This cop does not work well if the method name starts with underscore.

related: #6125

@pocke pocke self-assigned this Jan 26, 2019
pocke added a commit to pocke/rubocop that referenced this issue Jan 26, 2019
koic added a commit that referenced this issue Jan 26, 2019
[Fix #6710] Fix `Naming/MemoizedInstanceVariableName` on method starts with underscore
@Drenmi Drenmi mentioned this issue Feb 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants