diff --git a/lib/puppet-lint/plugins/check_strict_indent.rb b/lib/puppet-lint/plugins/check_strict_indent.rb index 81a3828..4510660 100644 --- a/lib/puppet-lint/plugins/check_strict_indent.rb +++ b/lib/puppet-lint/plugins/check_strict_indent.rb @@ -131,9 +131,9 @@ def check actual = 0 if token.next_token.type == :INDENT actual = token.next_token.value.length - elsif token.prev_token.type == :HEREDOC + elsif !token.prev_token.nil? and token.prev_token.type == :HEREDOC actual = token.prev_token.value.split("\n").last.length - elsif token.prev_token.type == :HEREDOC_OPEN + elsif !token.prev_token.nil? and token.prev_token.type == :HEREDOC_OPEN actual = next_token.prev_token.value.split("\n").last.length else actual = 0 diff --git a/spec/puppet-lint/plugins/check_strict_indent_spec.rb b/spec/puppet-lint/plugins/check_strict_indent_spec.rb index d3de4d5..ce14b15 100644 --- a/spec/puppet-lint/plugins/check_strict_indent_spec.rb +++ b/spec/puppet-lint/plugins/check_strict_indent_spec.rb @@ -77,4 +77,17 @@ class ( expect(problems).to have(1).problems end end + + context 'blank line at beginning of file' do + let(:code) { + <<-EOF.gsub(/^ {8}/, '') + + class () {} + EOF + } + + it 'should detect 0 problems' do + expect(problems).to have(0).problems + end + end end