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
class << self is ignored in Metrics/ModuleLength #12231
Comments
This is detected by |
@koic I'm not sure if this is correct behaviour, if it is then feel free to close this ticket: Given this configuration: AllCops:
DisabledByDefault: true
Metrics/ModuleLength:
Max: 1
Metrics/ClassLength:
Max: 1 For this case: module TestModule
class << self
def a
end
end
end we'll get:
but for this case: module TestModule
class << self
def a
end
end
def a; end
end we'll get both:
|
There was a change in behaviour between 1.49.0 and 1.50.0: # testfile
module TestModule
class << self
def a
end
end
end there is a difference in which cop reacts:
I assume it's because of either #11773 or #11776 so at this point I'm just not sure if both cops shouldn't react in this case or if the current behaviour is the correct and expected one |
You're right. This is an unexpected change in behavior. I've opened #12240 to resolve this issue. Thank you! |
Fixes rubocop#12231. This PR fixes a false negative for `Metrics/ModuleLength` when defining a singleton class in a module.
…module_length [Fix #12231] Fix a false negative for `Metrics/ModuleLength`
Expected behavior
The code inside
class << self
should be counted towards module lengthActual behavior
The contents of the block are ignored and
Metrics/ModuleLength
passesSteps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: