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/TrivialAccessors incorrectly suggests using attr_writer for a method that stores a block #1694

Closed
shepmaster opened this issue Mar 6, 2015 · 0 comments

Comments

@shepmaster
Copy link

class Foo
  def foo(&blk)
    @foo = blk
  end

  def thing
    @foo.call(1)
  end
end

f = Foo.new
f.foo { |x| x + 1 }
puts f.thing

Suggests:

/tmp/a.rb:4:3: C: Use attr_writer to define trivial writer methods.
  def foo(&blk)
  ^^^

I tried an attr_writer just in case, but it didn't work 😸 .

$ rubocop --version
0.29.1
$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
@bbatsov bbatsov closed this as completed in 793a2b8 Mar 7, 2015
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

1 participant