Skip to content

Commit d22a4b7

Browse files
committed
Fix issue with blank line at the beginning of a file.
1 parent f018c92 commit d22a4b7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/puppet-lint/plugins/check_strict_indent.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ def check
131131
actual = 0
132132
if token.next_token.type == :INDENT
133133
actual = token.next_token.value.length
134-
elsif token.prev_token.type == :HEREDOC
134+
elsif !token.prev_token.nil? and token.prev_token.type == :HEREDOC
135135
actual = token.prev_token.value.split("\n").last.length
136-
elsif token.prev_token.type == :HEREDOC_OPEN
136+
elsif !token.prev_token.nil? and token.prev_token.type == :HEREDOC_OPEN
137137
actual = next_token.prev_token.value.split("\n").last.length
138138
else
139139
actual = 0

spec/puppet-lint/plugins/check_strict_indent_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,17 @@ class (
7777
expect(problems).to have(1).problems
7878
end
7979
end
80+
81+
context 'blank line at beginning of file' do
82+
let(:code) {
83+
<<-EOF.gsub(/^ {8}/, '')
84+
85+
class () {}
86+
EOF
87+
}
88+
89+
it 'should detect 0 problems' do
90+
expect(problems).to have(0).problems
91+
end
92+
end
8093
end

0 commit comments

Comments
 (0)