Skip to content

Commit

Permalink
Merge pull request #17 from scalefactory/start_with_blank_line_Fix
Browse files Browse the repository at this point in the history
Fix issue with blank line at the beginning of a file.
  • Loading branch information
relud authored Feb 7, 2019
2 parents f018c92 + d22a4b7 commit f4c0056
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puppet-lint/plugins/check_strict_indent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions spec/puppet-lint/plugins/check_strict_indent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f4c0056

Please sign in to comment.