Skip to content

Commit

Permalink
add blank line after writing annotations
Browse files Browse the repository at this point in the history
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
  • Loading branch information
ashutosh-narkar committed Feb 22, 2024
1 parent 8aca267 commit 9f701a7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions format/format.go
Expand Up @@ -381,16 +381,20 @@ func (w *writer) writeComments(comments []*ast.Comment) {
}

func (w *writer) writeRules(rules []*ast.Rule, o fmtOpts, comments []*ast.Comment) []*ast.Comment {
existingAnnotations, _ := ast.ParseAnnotations(comments)
parsedAnnotations, _ := ast.ParseAnnotations(comments)

for _, rule := range rules {

if len(existingAnnotations) == 0 {
if len(parsedAnnotations) == 0 {
for _, an := range rule.Annotations {
w.blankLine()
w.writeLine("# METADATA")
w.writeComments(an.Comments())
}

// add a blank line to separate annotations from trailing comments to avoid errors during
// annotation parsing which expects a blank line between them
w.blankLine()
}

comments = w.insertComments(comments, rule.Location)
Expand Down

0 comments on commit 9f701a7

Please sign in to comment.