Skip to content

Commit b56672d

Browse files
authored
Merge pull request #86 from nwoythal/fix-first-token-whitespace
2 parents d1cdc01 + a9e7c21 commit b56672d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def fix(problem)
3030

3131
prev_token = problem[:token].prev_token
3232
next_token = problem[:token].next_token
33-
prev_token.next_token = next_token
33+
prev_token.next_token = next_token unless prev_token.nil?
3434
next_token.prev_token = prev_token unless next_token.nil?
3535
tokens.delete(problem[:token])
3636
end

spec/unit/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,17 @@
105105
expect(manifest).to eq(fixed)
106106
end
107107
end
108+
109+
context 'empty lines with nothing but whitespace' do
110+
let(:code) { " \n " }
111+
112+
it 'detects problems with both empty lines' do
113+
expect(problems).to have(2).problem
114+
end
115+
116+
it 'fixes the manifest' do
117+
expect(manifest).to eq("\n")
118+
end
119+
end
108120
end
109121
end

0 commit comments

Comments
 (0)