-
Notifications
You must be signed in to change notification settings - Fork 281
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 positive for ModuleInitialize #1505
Labels
Comments
JuanVqz
added a commit
to JuanVqz/reek
that referenced
this issue
Oct 18, 2023
JuanVqz
added a commit
to JuanVqz/reek
that referenced
this issue
Oct 18, 2023
JuanVqz
added a commit
to JuanVqz/reek
that referenced
this issue
Oct 18, 2023
JuanVqz
added a commit
to JuanVqz/reek
that referenced
this issue
Oct 21, 2023
In a very similar case, I also get a false positive for this rule when defining a Data class with an initializer. module Example
Thing = Data.define(:value) do
def initialize(value: 'some default')
super(value:)
end
end
end |
mvz
changed the title
False positive for MonduleInitialize
False positive for ModuleInitialize
Dec 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've come across two instances of a false positive ModuleInitialize warnings when using anonymous class definitions.
First the RSpec related one:
And secondly a DSL-based one:
The DSL variant is probably not very likely to be done in a real-world scenario, but technically the
initialize
method is not defined on the module that Reek warns about. The RSpec variant is something I've come across in the real world however.If the anonymous class is assigned to a constant it does not fail however, which makes sense cause it's no longer an anonymous class:
A slightly different variant of this was reported in #1137 and fixed in #1287, but it specifically requires the anonymous class definition to be within a method definition on the module. Hence both of these are not reported:
The text was updated successfully, but these errors were encountered: