Class: RuboCop::Cask::AST::Stanza Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
rubocops/cask/ast/stanza.rb,
sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.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 class wraps the AST send/block node that encapsulates the method call that comprises the stanza. It includes various helper methods to aid cops in their analysis.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_node, all_comments) ⇒ Stanza

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.

Returns a new instance of Stanza.



15
16
17
18
# File 'rubocops/cask/ast/stanza.rb', line 15

def initialize(method_node, all_comments)
  @method_node = method_node
  @all_comments = all_comments
end

Instance Attribute Details

#all_commentsObject (readonly)

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.



20
21
22
# File 'rubocops/cask/ast/stanza.rb', line 20

def all_comments
  @all_comments
end

#method_nodeObject (readonly) Also known as: stanza_node

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.



20
21
22
# File 'rubocops/cask/ast/stanza.rb', line 20

def method_node
  @method_node
end

Instance Method Details

#arch_variable?(*args, &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:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (Boolean)


10
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 10

def arch_variable?(*args, &block); end

#commentsObject

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.



60
61
62
63
64
# File 'rubocops/cask/ast/stanza.rb', line 60

def comments
  @comments ||= stanza_node.each_node.reduce([]) do |comments, node|
    comments | comments_hash[node.loc]
  end
end

#comments_hashObject

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.



66
67
68
# File 'rubocops/cask/ast/stanza.rb', line 66

def comments_hash
  @comments_hash ||= Parser::Source::Comment.associate_locations(stanza_node.parent, all_comments)
end

#on_system_block?(*args, &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:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (Boolean)


13
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 13

def on_system_block?(*args, &block); end

#parent_node(*args, &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:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


16
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 16

def parent_node(*args, &block); end

#same_group?(other) ⇒ 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.

Returns:

  • (Boolean)


56
57
58
# File 'rubocops/cask/ast/stanza.rb', line 56

def same_group?(other)
  stanza_group == other.stanza_group
end

#source(*args, &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:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


19
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 19

def source(*args, &block); end

#source_rangeObject

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.



28
29
30
# File 'rubocops/cask/ast/stanza.rb', line 28

def source_range
  stanza_node.location_expression
end

#source_range_with_commentsObject

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.



32
33
34
35
36
# File 'rubocops/cask/ast/stanza.rb', line 32

def source_range_with_comments
  comments.reduce(source_range) do |range, comment|
    range.join(comment.loc.expression)
  end
end

#source_with_comments(*args, &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:

  • args (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


22
# File 'sorbet/rbi/dsl/rubo_cop/cask/ast/stanza.rbi', line 22

def source_with_comments(*args, &block); end

#stanza_groupObject

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.



48
49
50
# File 'rubocops/cask/ast/stanza.rb', line 48

def stanza_group
  Constants::STANZA_GROUP_HASH[stanza_name]
end

#stanza_indexObject

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
# File 'rubocops/cask/ast/stanza.rb', line 52

def stanza_index
  Constants::STANZA_ORDER.index(stanza_name)
end

#stanza_nameObject

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.



42
43
44
45
46
# File 'rubocops/cask/ast/stanza.rb', line 42

def stanza_name
  return :on_arch_conditional if arch_variable?

  stanza_node.method_name
end