Module: RuboCop::Cop::DefNode
- Extended by:
- NodePattern::Macros
- Included in:
- Style::DocumentationMethod
- Defined in:
- lib/rubocop/cop/mixin/def_node.rb
Overview
Common functionality for checking def nodes.
Constant Summary collapse
- NON_PUBLIC_MODIFIERS =
%w[private protected].freeze
Instance Method Summary collapse
Methods included from NodePattern::Macros
def_node_matcher, def_node_search, node_search, node_search_all, node_search_body, node_search_first
Instance Method Details
#non_public?(node) ⇒ Boolean
11 12 13 14 |
# File 'lib/rubocop/cop/mixin/def_node.rb', line 11 def non_public?(node) non_public_modifier?(node.parent) || preceding_non_public_modifier?(node) end |
#preceding_non_public_modifier?(node) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/rubocop/cop/mixin/def_node.rb', line 16 def preceding_non_public_modifier?(node) stripped_source_upto(node.loc.line).any? do |line| NON_PUBLIC_MODIFIERS.include?(line) end end |