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
Naming/AccessorMethodName not flagging all functions in some ruby files, even when explicitly included #7801
Comments
I ran into something like this. After testing, I believe the cop does not treat singleton accessor methods (module and class methods) as offenses, since singleton methods are (in principle) free functions and not bound to an object instance. For example: module Foo
def get_this_gets_caught
'foo'
end
def self.get_this_does_not
'foo'
end
end |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
This cop is working as expected. Both instance and class methods are considered, and it is not limited to certain paths.
However, the cop only checks for methods with the correct arity: getters must have 0 arguments and setters must have 1. I am opening a PR to update the documentation in that regard. |
The cop "Naming/AccessorMethodName" is not flagging all functions that start with
get_
andset_
in some ruby files, even when explicitly including the files in the rubocop config.We want to discourage our coders from using any function starting with
get_
andset_
by including all files within the ruby app.Expected behavior
Rubocop flagging all functions that start with starting with
get_
andset_
in all ruby files that are added to theInclude
in the "Naming/AccessorMethodName" rubocop config.Actual behavior
Rubocop flags functions that start with
get_
andset_
only in certain ruby files such as controllers and modes while ignoring files added to theInclude
.Steps to reproduce the problem
Add the following rule to the
.rubocop.yml
Create a function starting with
get_something_from(id)
inapp/services/external_source.rb
Run rubocop
bundle exec rubocop
RuboCop version
The text was updated successfully, but these errors were encountered: