-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Expected behavior
Expected the line after the closing parenthesis of Struct.new(...) to be checked for Layout/EmptyLinesAroundClassBody, in the event that the class inherits from Struct.new and is declared in a multiline format.
Actual behavior
Keeps revolving between
Layout/EmptyLinesAroundClassBody: Empty line missing at class body beginning,
Layout/EmptyLinesAroundArguments: Empty line detected around arguments.
in an infinite loop.
screenshots of the two formats:
Steps to reproduce the problem
This seems to get applied once I extend the class to have a def initialize method... it must at that point get registered as a "block" class instead of a class that is defined "inline":
class Event < Struct.new(
:message, # it checks this line for the space
:severity,
keyword_init: true,
)
# this is the space I expected it to look at for Layout/EmptyLinesAroundClassBody
def initialize(severity: :warning, **args)
super(severity: severity, **args)
end
endI tried to create a regex pattern that would work with AllowedPatterns, but the issue is that RuboCop compares the regex 1 line in the source code at a time - so I'm unable to create a multiline regex pattern that captures \sclass.<\sStruct.new( and then disables this for the next line (or do ^sclass.<\sStruct.new(\n.*:[a-z_]+,).
RuboCop version
❯ rubocop -v
1.79.1