rubocops/cask: Use ON_SYSTEM_METHODS for skipping

Co-authored-by: Rylan Polster <rslpolster@gmail.com>
This commit is contained in:
Issy Long 2023-03-19 19:19:00 +00:00
parent 9cc046bc60
commit 5ce4966f4a
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -20,7 +20,7 @@ module RuboCop
# TODO: We probably only want to disallow `version`, `url`, and `sha256` stanzas being overridden? # TODO: We probably only want to disallow `version`, `url`, and `sha256` stanzas being overridden?
next unless RuboCop::Cask::Constants::STANZA_ORDER.include?(stanza.stanza_name) next unless RuboCop::Cask::Constants::STANZA_ORDER.include?(stanza.stanza_name)
# Skip if the stanza we detect is already in an `on_*` block. # Skip if the stanza we detect is already in an `on_*` block.
next if stanza.parent_node.block_type? && stanza.parent_node.method_name.to_s.start_with?("on_") next if stanza.parent_node.block_type? && RuboCop::Cask::Constants::ON_SYSTEM_METHODS.include?(stanza.parent_node.method_name)
add_offense(stanza.source_range, message: format(MESSAGE, stanza: stanza.stanza_name)) add_offense(stanza.source_range, message: format(MESSAGE, stanza: stanza.stanza_name))
end end