Class: RuboCop::Cop::Homebrew::Present Private

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
rubocops/present.rb,
sorbet/rbi/dsl/rubo_cop/cop/homebrew/present.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.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in RuboCop::Cop::Homebrew::Present. Please instead update this file by running bin/tapioca dsl RuboCop::Cop::Homebrew::Present.

Constant Summary collapse

MSG =

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 `%<prefer>s` instead of `%<current>s`."

Instance Method Summary collapse

Instance Method Details

#autocorrect(corrector, node) ⇒ Object

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.



62
63
64
65
66
# File 'rubocops/present.rb', line 62

def autocorrect(corrector, node)
  variable1, _variable2 = exists_and_not_empty?(node)
  range = node.source_range
  corrector.replace(range, replacement(variable1))
end

#exists_and_not_empty?(node, **kwargs, &block) ⇒ T.untyped

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:

Returns:

  • (T.untyped)


9
# File 'sorbet/rbi/dsl/rubo_cop/cop/homebrew/present.rbi', line 9

def exists_and_not_empty?(node, **kwargs, &block); end

#on_and(node) ⇒ Object

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.



40
41
42
43
44
45
46
47
48
49
50
# File 'rubocops/present.rb', line 40

def on_and(node)
  exists_and_not_empty?(node) do |var1, var2|
    return if var1 != var2

    message = format(MSG, prefer: replacement(var1), current: node.source)

    add_offense(node, message:) do |corrector|
      autocorrect(corrector, node)
    end
  end
end

#on_or(node) ⇒ Object

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.



52
53
54
55
56
57
58
59
60
# File 'rubocops/present.rb', line 52

def on_or(node)
  exists_and_not_empty?(node) do |var1, var2|
    return if var1 != var2

    add_offense(node, message: MSG) do |corrector|
      autocorrect(corrector, node)
    end
  end
end