Class: Rubocop::Cop::Style::AccessModifierIndentation
- Includes:
- AutocorrectAlignment, ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/style/access_modifier_indentation.rb
Overview
Modifiers should be indented as deep as method definitions, or as deep as the class/module keyword, depending on configuration.
Constant Summary collapse
- MSG =
'%s access modifiers like `%s`.'
- PRIVATE_NODE =
s(:send, nil, :private)
- PROTECTED_NODE =
s(:send, nil, :protected)
- PUBLIC_NODE =
s(:send, nil, :public)
Constants included from Util
Util::ASGN_NODES, Util::EQUALS_ASGN_NODES, Util::OPERATOR_METHODS, Util::PROC_NEW_NODE, Util::SHORTHAND_ASGN_NODES
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offenses, #processed_source
Class Method Summary collapse
Instance Method Summary collapse
- #on_block(node) ⇒ Object
- #on_class(node) ⇒ Object
- #on_module(node) ⇒ Object
- #on_sclass(node) ⇒ Object
Methods included from ConfigurableEnforcedStyle
#alternative_style, #both_styles_detected, #correct_style_detected, #opposite_style_detected, #parameter_name, #style, #unrecognized_style_detected
Methods included from AutocorrectAlignment
#autocorrect, #calculate_range, #check_alignment, #each_line, #remove, #start_of_line?
Methods inherited from Cop
#add_offense, all, #autocorrect?, #config_to_allow_offenses, #config_to_allow_offenses=, #cop_config, cop_name, #cop_name, cop_type, #debug?, #display_cop_names?, #exclude_file?, #include_file?, inherited, #initialize, lint?, non_rails, rails?, #relevant_file?, #support_autocorrect?
Methods included from IgnoredNode
#ignore_node, #ignored_node?, #part_of_ignored_node?
Methods included from Util
block_length, command?, comment_line?, const_name, first_part_of_call_chain, lambda?, lambda_or_proc?, line_range, on_node, operator?, parentheses?, proc?, range_with_surrounding_space, source_range, strip_quotes
Methods included from PathUtil
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Class Method Details
.modifier_node?(node) ⇒ Boolean
38 39 40 |
# File 'lib/rubocop/cop/style/access_modifier_indentation.rb', line 38 def self.modifier_node?(node) [PRIVATE_NODE, PROTECTED_NODE, PUBLIC_NODE].include?(node) end |
Instance Method Details
#on_block(node) ⇒ Object
33 34 35 36 |
# File 'lib/rubocop/cop/style/access_modifier_indentation.rb', line 33 def on_block(node) _method, _args, body = *node check_body(body, node) if class_constructor?(node) end |
#on_class(node) ⇒ Object
18 19 20 21 |
# File 'lib/rubocop/cop/style/access_modifier_indentation.rb', line 18 def on_class(node) _name, _base_class, body = *node check_body(body, node) end |
#on_module(node) ⇒ Object
28 29 30 31 |
# File 'lib/rubocop/cop/style/access_modifier_indentation.rb', line 28 def on_module(node) _name, body = *node check_body(body, node) end |
#on_sclass(node) ⇒ Object
23 24 25 26 |
# File 'lib/rubocop/cop/style/access_modifier_indentation.rb', line 23 def on_sclass(node) _name, body = *node check_body(body, node) end |