Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aca8aaf

Browse files
authored
Merge pull request rubocop#614 from rubocop-rspec/fix-aligh-brace-with-empty-file
Fix investigation of empty files
2 parents 22fd443 + 9abd734 commit aca8aaf

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

lib/rubocop/cop/rspec/align_left_let_brace.rb

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def self.autocorrect_incompatible_with
2525
end
2626

2727
def investigate(_processed_source)
28+
return if processed_source.blank?
29+
2830
token_aligner.offending_tokens.each do |let|
2931
add_offense(let, location: :begin)
3032
end

lib/rubocop/cop/rspec/align_right_let_brace.rb

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def self.autocorrect_incompatible_with
2525
end
2626

2727
def investigate(_processed_source)
28+
return if processed_source.blank?
29+
2830
token_aligner.offending_tokens.each do |let|
2931
add_offense(let, location: :end)
3032
end

spec/rubocop/cop/rspec/align_left_let_brace_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
RUBY
2525
end
2626

27+
it 'works with empty file' do
28+
expect_no_offenses('')
29+
end
30+
2731
offensive_source = <<-RUBY
2832
let(:foo) { bar }
2933
let(:hi) { baz }

spec/rubocop/cop/rspec/align_right_let_brace_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
RUBY
2525
end
2626

27+
it 'works with empty file' do
28+
expect_no_offenses('')
29+
end
30+
2731
offensive_source = <<-RUBY
2832
let(:foo) { a }
2933
let(:hi) { ab }

0 commit comments

Comments
 (0)