Sha256: 64a0f90f93ded28ac4faaafaff42da8dff13e71c01011b1b518c06b8187c3ad2

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Checks that right 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        }
      #
      class AlignRightLetBrace < Base
        extend AutoCorrector

        MSG = 'Align right let brace'

        def self.autocorrect_incompatible_with
          [Layout::ExtraSpacing]
        end

        def on_new_investigation
          return if processed_source.blank?

          token_aligner =
            RuboCop::RSpec::AlignLetBrace.new(processed_source.ast, :end)

          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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-rspec-2.0.0.pre lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-1.44.1 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-1.44.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-1.43.2 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-1.43.1 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-1.43.0 lib/rubocop/cop/rspec/align_right_let_brace.rb