Class: RuboCop::Cop::Cask::StanzaOrder
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Cask::StanzaOrder
- Extended by:
- Forwardable
- Includes:
- CaskHelp
- Defined in:
- lib/rubocop/cop/cask/stanza_order.rb
Overview
This cop checks that a cask’s stanzas are ordered correctly. See github.com/caskroom/homebrew-cask/blob/master/CONTRIBUTING.md#stanza-order for more info.
Constant Summary collapse
- MESSAGE =
'`%<stanza>s` stanza out of order'.freeze
Instance Method Summary collapse
Methods included from CaskHelp
Instance Method Details
#autocorrect(stanza) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/rubocop/cop/cask/stanza_order.rb', line 20 def autocorrect(stanza) lambda do |corrector| correct_stanza_index = toplevel_stanzas.index(stanza) correct_stanza = sorted_toplevel_stanzas[correct_stanza_index] corrector.replace(stanza.source_range_with_comments, correct_stanza.source_with_comments) end end |
#on_cask(cask_block) ⇒ Object
15 16 17 18 |
# File 'lib/rubocop/cop/cask/stanza_order.rb', line 15 def on_cask(cask_block) @cask_block = cask_block add_offenses end |