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

TrivialAccessors gives false advice on modules with module_function #2059

Closed
alexanderadam opened this issue Jul 22, 2015 · 2 comments
Closed

Comments

@alexanderadam
Copy link

TrivialAccessors complains with

Use attr_writer to define trivial writer methods.
  def bar=(new_bar)
  ^^^

in a case like

module Foo
  module_function

  def bar=(new_bar)
    @bar = new_bar
  end
end

module Bar
  module_function

  attr_writer :foo
end

Foo.bar = 'works'
Bar.foo = "this doesn't"

but ruby will complain with

undefined method `foo=' for Bar:Module (NoMethodError)

when following TrivialAccessors advice.

PS: @bbatsov thank you for your work! I love rubo:cop:!

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 22, 2015

Ah, yeah. Seems the best solution would be to simply ignore modules altogether in this cop.

Alternative suggestions are welcome.

@alexanderadam
Copy link
Author

I guess it would be the simplest solution for now so… yes

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