Skip to content

Commit 5ded3fb

Browse files
authored
Merge pull request #2 from wreulicke/feature/suggested-fix
Support suggested fix
2 parents facb4e6 + 904b2a1 commit 5ded3fb

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pkg/nlreturn/nlreturn.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package nlreturn
22

33
import (
4+
"fmt"
45
"go/ast"
56
"go/token"
67

@@ -49,7 +50,21 @@ func inspectBlock(pass *analysis.Pass, block []ast.Stmt) {
4950
}
5051

5152
if line(pass, stmt.Pos())-line(pass, block[i-1].End()) <= 1 {
52-
pass.Reportf(stmt.Pos(), "%s with no blank line before", name(stmt))
53+
pass.Report(analysis.Diagnostic{
54+
Pos: stmt.Pos(),
55+
Message: fmt.Sprintf("%s with no blank line before", name(stmt)),
56+
SuggestedFixes: []analysis.SuggestedFix{
57+
{
58+
TextEdits: []analysis.TextEdit{
59+
{
60+
Pos: stmt.Pos(),
61+
NewText: []byte("\n"),
62+
End: stmt.Pos(),
63+
},
64+
},
65+
},
66+
},
67+
})
5368
}
5469
}
5570
}

0 commit comments

Comments
 (0)