Skip to content

Commit

Permalink
Merge pull request #39 from thaim/blank-line-rule-error
Browse files Browse the repository at this point in the history
  • Loading branch information
thaim authored Sep 26, 2023
2 parents ceb0b3b + aed2429 commit b509b4f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rules/formatter_blank_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *FormatterBlankLineRule) checkFileEnd(runner tflint.Runner, name string,
totalLine := countLines(runes)
line := 0

for ; line < totalLine; line++ {
for ; line < len(runes); line++ {
if runes[len(runes)-line-1] != '\n' {
break
}
Expand Down
16 changes: 16 additions & 0 deletions rules/formatter_blank_line_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ resource "null_resource" "second" {
},
},
},
{
Name: "only blank line",
Content: `
`,
Expected: helper.Issues{
{
Rule: NewFormatterBlankLineRule(),
Message: "too many blank lines at start of file",
Range: hcl.Range{
Filename: "resource.tf",
Start: hcl.Pos{Line: 1, Column: 1},
End: hcl.Pos{Line: 2, Column: 1},
},
},
},
},
}

rule := NewFormatterBlankLineRule()
Expand Down

0 comments on commit b509b4f

Please sign in to comment.