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

Allow configuration of visibility_and_def_on_same_line? method #1467

Closed
maksar opened this issue Nov 26, 2014 · 5 comments
Closed

Allow configuration of visibility_and_def_on_same_line? method #1467

maksar opened this issue Nov 26, 2014 · 5 comments

Comments

@maksar
Copy link

maksar commented Nov 26, 2014

Ruby 2.1 syntax allows method modifiers to be placed right before method declarations, like:

private def current_profile
  current_user.profile
end

Currently, only [:public, :protected, :private, :module_function]method modifiers supported.
It would be nice to have this list configured by .rubocop.yml file. In particular, Rails features like helper_method or before_action, etc.:

helper_method def current_profile
  current_user.profile
end

All mentioned happens in lib/rubocop/cop/mixin/on_method.rb file. Please, suggest similar place in codebase, where such configuration is already implement, so I can take a look and create a pull request for this ticket.

@MartynasM
Copy link

I am having this issue using Memoist gem one of the use cases is

memoize def method_name
  method_body
end

@jpalumickas
Copy link

Yep, this would be nice ! 👍

@fphilipe
Copy link
Contributor

fphilipe commented Jul 2, 2015

Just came across this myself. What about not caring what comes before the def?

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 2, 2015

Patches welcome. :-)

@fphilipe
Copy link
Contributor

fphilipe commented Jul 2, 2015

@bbatsov Would you say it's OK not to check what comes before def or would you prefer the list of allowed words to be configurable?

fphilipe added a commit to fphilipe/rubocop that referenced this issue Jul 2, 2015
Previously, only certain methods primarily related to method visibility
were allowed before a `def`. This changes the behavior such that
anything before `def` is allowed.

Closes rubocop#1467
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

5 participants