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
I have some code that generates a Struct that has some methods added to it:
def listener @listener ||= Struct.new(:thing, :to, :listen_to) do def all_the_things "#{thing} #{to} #{listen_to}" end end end
According to http://ruby-doc.org/core-2.2.0/Struct.html, this is the recommended way to customize a struct, but this code fails the cop:
$ bundle exec rubocop -D test.rb Inspecting 1 file W Offenses: test.rb:3:5: W: Lint/NestedMethodDefinition: Method definitions must not be nested. Use lambda instead. def all_the_things ... ^^^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected
The method above should trigger the cop.
Include the output of rubocop -V:
rubocop -V
$ rubocop -V 0.39.0 (using Parser 2.3.0.7, running on ruby 2.2.4 x86_64-linux-musl)
The text was updated successfully, but these errors were encountered:
fb62662
Merge pull request #3053 from owst/do_not_consider_defs_in_Struct_new…
603df7f
…_as_nested [Fix #3048] Do not report defs in Struct.new block as nested
[Fix rubocop#3048] Do not report defs in Struct.new block as nested
d21e828
No branches or pull requests
I have some code that generates a Struct that has some methods added to it:
According to http://ruby-doc.org/core-2.2.0/Struct.html, this is the recommended way to customize a struct, but this code fails the cop:
Steps to reproduce the problem
The method above should trigger the cop.
RuboCop version
Include the output of
rubocop -V
:The text was updated successfully, but these errors were encountered: