Class: RuboCop::Cop::RSpec::AlignRightLetBrace

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/rspec/align_right_let_brace.rb

Overview

Checks that right braces for adjacent single line lets are aligned.

Examples:


# bad
let(:foobar) { blahblah }
let(:baz)    { bar }
let(:a)      { b }

# good
let(:foobar) { blahblah }
let(:baz)    { bar      }
let(:a)      { b        }

Constant Summary collapse

MSG =
'Align right let brace'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited

Methods included from RSpec::Language::NodePattern

#block_pattern, #send_pattern

Class Method Details

.autocorrect_incompatible_withObject


25
26
27
# File 'lib/rubocop/cop/rspec/align_right_let_brace.rb', line 25

def self.autocorrect_incompatible_with
  [Layout::ExtraSpacing]
end

Instance Method Details

#on_new_investigationObject


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rubocop/cop/rspec/align_right_let_brace.rb', line 29

def on_new_investigation
  super
  return if processed_source.blank?

  token_aligner.offending_tokens.each do |let|
    add_offense(let.loc.end) do |corrector|
      corrector.insert_before(
        let.loc.end, token_aligner.indent_for(let)
      )
    end
  end
end