-
-
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
false offense detected by Style/MixinUsage #4885
Comments
It looks like this cop misreports for any case where the class is the first in some set of siblings. For example: class A
include Mixin
end
class B
include Mixin
end Result:
Of note is that only the first class has this error reported.
|
I'm also getting false positives for this:
Again, strangely, only for the first occurrence in a file. I define three matchers in one file, all with the same mixin, and only get flagged for the first one. ..... It is a bit unclear from the mixin code itself and the PR what the goal of the cop is. Is it really to prevent mixing into |
I have the same problem, and another info.
Rubocop will raise Style/MixinUsage only for module_A and module_D, not the namespaced ones.
|
Indeed. It's a bit unclear what the implementation is trying to do, but it's clear that it's incorrect. 🙂 |
Fixes rubocop#4885. This change makes the following modification based on Issue's report. ## Using `include` inside block The follwing does not register an offense. ```ruby Class.new do include IsNameValueType end ``` and ```ruby RSpec::Matchers.define :do_something do include Mixin end ``` ## Multiple definition classes in one The follwing does not register an offense. ```ruby class C1 include M end class C2 include M end ``` ## Nested module The follwing register an offense. ```ruby include M1::M2::M3 class C end ```
Fixes #4885. This change makes the following modification based on Issue's report. ## Using `include` inside block The follwing does not register an offense. ```ruby Class.new do include IsNameValueType end ``` and ```ruby RSpec::Matchers.define :do_something do include Mixin end ``` ## Multiple definition classes in one The follwing does not register an offense. ```ruby class C1 include M end class C2 include M end ``` ## Nested module The follwing register an offense. ```ruby include M1::M2::M3 class C end ```
Is there any fix on this? It's still popping up for me. |
@ZASMan |
Expected behavior
expect Mixin usage to be correct
Actual behavior
Steps to reproduce the problem
create the test as in the expected behaviour and run
rubocop <filename>
RuboCop version
Include the output of
rubocop -V
. Here's an example:The text was updated successfully, but these errors were encountered: