Class: RuboCop::Cop::Cask::Discontinued Private

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
CaskHelp
Defined in:
rubocops/cask/discontinued.rb,
rubocops/cask/discontinued.rbi

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

This cop corrects caveats { discontinued } to deprecate!.

Constant Summary collapse

MESSAGE =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

"Use `deprecate!` instead of `caveats { discontinued }`."

Instance Method Summary collapse

Methods included from CaskHelp

#cask_tap, #inner_stanzas, #on_block, #on_cask, #on_system_methods

Instance Method Details

#caveats_contains_only_discontinued?(base_node, &block) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • base_node (RuboCop::AST::Node)
  • block (T.proc.params(node: RuboCop::AST::SendNode).void, nil)

Returns:

  • (Boolean)


13
# File 'rubocops/cask/discontinued.rbi', line 13

def caveats_contains_only_discontinued?(base_node, &block); end

#find_discontinued_method_call(base_node, &block) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



21
# File 'rubocops/cask/discontinued.rbi', line 21

def find_discontinued_method_call(base_node, &block); end

#on_cask_stanza_block(stanza_block) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'rubocops/cask/discontinued.rb', line 15

def on_cask_stanza_block(stanza_block)
  stanza_block.stanzas.select(&:caveats?).each do |stanza|
    find_discontinued_method_call(stanza.stanza_node) do |node|
      if caveats_contains_only_discontinued?(node.parent)
        add_offense(node.parent, message: MESSAGE) do |corrector|
          corrector.replace(node.parent.source_range,
                            "deprecate! date: \"#{Date.today}\", because: :discontinued")
        end
      else
        add_offense(node, message: MESSAGE)
      end
    end
  end
end