-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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/UselessMethodDefinition
false positive with default method arguments
#8561
Comments
cc @fatkodima |
This cop is already marked as unsafe. Currently, it is not possible to tell if def expect_offense(source, filename = DEFAULT_FILENAME, *args, **kwargs)
super
end changes method definition or just duplicates it, so seems like better to wrap the code with If we will specially handle default arguments (ignore, for example), we can possibly miss some legitimate cases. |
Static analysis is unable to tell. However, common sense suggests that it's not necessary to keep the default value if it was defined in the overridden method. We don't seem to be dealing with copypasted methods, as
"The definition of safety is that the cop doesn’t generate false positives". Got it.
What are those legitimate cases? |
I agree with @pirj here. If the |
I gave this another thought - yeah, this is reasonable. |
Lint/UselessMethodDefinition detects an offence in the following code:
However, we're overloading the existing definition, and set a default value for the argument.
It doesn't matter if the default value is overloaded or it's a required positional argument, this method definition is not useless.
I guess the same applies to kwargs's default values.
The build: https://app.circleci.com/pipelines/github/rubocop-hq/rubocop-rspec/437/workflows/8378280c-b36f-4b38-93f8-2dd33e09b9cb/jobs/16059
Expected behavior
No offence.
Actual behavior
Steps to reproduce the problem
See the description
RuboCop version
Can't reproduce locally.
Local:
CI:
The text was updated successfully, but these errors were encountered: