Sha256: 0956405c272e428926cdae1de30169ffc538fddc9aa298f8bd1bfcfde0631bbf

Contents?: true

Size: 1.12 KB

Versions: 53

Compression:

Stored size: 1.12 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
          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

        private

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

Version data entries

53 entries across 51 versions & 7 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-3.0.3/lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.3.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.2.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.1.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.0.5 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.0.4 lib/rubocop/cop/rspec/align_right_let_brace.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-rspec-3.0.1/lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.0.3 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.0.2 lib/rubocop/cop/rspec/align_right_let_brace.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-rspec-3.0.1/lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.0.1 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.0.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-3.0.0.pre lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-2.31.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-2.30.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-2.29.2 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-2.29.1 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-2.29.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-2.28.0 lib/rubocop/cop/rspec/align_right_let_brace.rb
rubocop-rspec-2.27.1 lib/rubocop/cop/rspec/align_right_let_brace.rb