class RuboCop::Cop::RSpec::AlignLeftLetBrace

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

@example

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

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

Constants

MSG

Public Class Methods

autocorrect_incompatible_with() click to toggle source
# File lib/rubocop/cop/rspec/align_left_let_brace.rb, line 23
def self.autocorrect_incompatible_with
  [Layout::ExtraSpacing]
end

Public Instance Methods

autocorrect(let) click to toggle source
# File lib/rubocop/cop/rspec/align_left_let_brace.rb, line 35
def autocorrect(let)
  lambda do |corrector|
    corrector.insert_before(
      let.loc.begin,
      token_aligner.indent_for(let)
    )
  end
end
investigate(_processed_source) click to toggle source
# File lib/rubocop/cop/rspec/align_left_let_brace.rb, line 27
def investigate(_processed_source)
  return if processed_source.blank?

  token_aligner.offending_tokens.each do |let|
    add_offense(let, location: :begin)
  end
end

Private Instance Methods

token_aligner() click to toggle source
# File lib/rubocop/cop/rspec/align_left_let_brace.rb, line 46
def token_aligner
  @token_aligner ||=
    RuboCop::RSpec::AlignLetBrace.new(processed_source.ast, :begin)
end