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

Lint/NestedMethodDefinition shouldn't flag singleton methods #2704

Closed
CyborgMaster opened this issue Jan 22, 2016 · 0 comments
Closed

Lint/NestedMethodDefinition shouldn't flag singleton methods #2704

CyborgMaster opened this issue Jan 22, 2016 · 0 comments

Comments

@CyborgMaster
Copy link

I have a function that returns an object, and decorates it with a patched method. This doesn't fall under the category of this cop because it doesn't create a method in the outer scope.

Flagged code:

  def medium_mock
    mock('medium') do |m|
      stubs(:get_search_ranges).returns([Object.new])
      stubs(:deliver)
      def m.select_fields(param)
        param
      end
      stubs type: 'test'
    end
  end

Offense:

Lint/NestedMethodDefinition: Method definitions must not be nested. Use lambda instead.
      def m.select_fields(param)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
$ rubocop -V
0.36.0 (using Parser 2.3.0.1, running on ruby 2.2.2 x86_64-darwin14)
@CyborgMaster CyborgMaster changed the title Lint/NestedMethodDefinition shouldn't flag object specific methods Lint/NestedMethodDefinition shouldn't flag singleton methods Jan 22, 2016
@bbatsov bbatsov closed this as completed in 67479ef Feb 9, 2016
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