You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling a method with the name ancestors on an object raises the rubocop-performance warning.
Is this possible to detect more correctly with static code analysis or are we out of luck? If not, honestly I would question the usefulness of this cop because I don't think we are the only ones to happen to have data models where something is called ancestors.
Expected behavior
rubocop-performance only warns when .ancestors is called on a Class.
Calling of the instance method should be fine
Actual behavior
It seems to screem at any calling of something called .ancestors
Steps to reproduce the problem
We have a rails model with the following association declaration
has_many:ancestors
Somewhere we have a test where usage this method - on the instance.
…ude`
Fixesrubocop#159.
This PR fixes a false positive for `Performance/AncestorsInclude`
when receiver is a variable.
As the cop's example shows, this change mainly targets when the receiver
is a constant. It can cause false negatives, but it may be less than
false positives.
And this change may lead to removing unsafe marked by rubocop#149.
Calling a method with the name
ancestors
on an object raises the rubocop-performance warning.Is this possible to detect more correctly with static code analysis or are we out of luck? If not, honestly I would question the usefulness of this cop because I don't think we are the only ones to happen to have data models where something is called
ancestors
.Expected behavior
rubocop-performance only warns when
.ancestors
is called on a Class.Calling of the instance method should be fine
Actual behavior
It seems to screem at any calling of something called
.ancestors
Steps to reproduce the problem
We have a rails model with the following association declaration
Somewhere we have a test where usage this method - on the instance.
expect(object_one.ancestors.include?(object_two)).to eq(true)
rubocop warns
RuboCop version
The text was updated successfully, but these errors were encountered: