Sha256: 6f0b7db1b3efea60940a470c21334654751a2745ba4f8798d760cfaf688ad4c0
Contents?: true
Size: 1.21 KB
Versions: 9
Compression:
Stored size: 1.21 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 < Cop MSG = 'Align right let brace'.freeze def self.autocorrect_incompatible_with [Layout::ExtraSpacing] end def investigate(_processed_source) return if processed_source.blank? token_aligner.offending_tokens.each do |let| add_offense(let, location: :end) end end def autocorrect(let) lambda do |corrector| corrector.insert_before( let.loc.end, token_aligner.indent_for(let) ) end end private def token_aligner @token_aligner ||= RuboCop::RSpec::AlignLetBrace.new(processed_source.ast, :end) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems