Class: RuboCop::Cop::HashAlignmentStyles::SeparatorAlignment
- Inherits:
-
Object
- Object
- RuboCop::Cop::HashAlignmentStyles::SeparatorAlignment
- Includes:
- ValueAlignment
- Defined in:
- lib/rubocop/cop/mixin/hash_alignment_styles.rb
Overview
Handles calculation of deltas when the enforced style is 'separator'.
Instance Method Summary collapse
-
#deltas(first_pair, current_pair) ⇒ Object
Keys are right-aligned by the column their last line ends on.
- #deltas_for_first_pair(_first_pair) ⇒ Object
Methods included from ValueAlignment
Instance Method Details
#deltas(first_pair, current_pair) ⇒ Object
Keys are right-aligned by the column their last line ends on. A key spanning several lines ends on a line other than the one it starts on, so moving its first line would never change that column and the correction would be repeated on every pass. Such pairs are left alone, and so is every pair when the first key spans several lines, since there is then no column to right-align to.
181 182 183 184 185 |
# File 'lib/rubocop/cop/mixin/hash_alignment_styles.rb', line 181 def deltas(first_pair, current_pair) return {} if first_pair.key.multiline? || current_pair.key.multiline? super end |
#deltas_for_first_pair(_first_pair) ⇒ Object
172 173 174 |
# File 'lib/rubocop/cop/mixin/hash_alignment_styles.rb', line 172 def deltas_for_first_pair(_first_pair) {} end |