Skip to content

Commit

Permalink
Merge pull request #2 from wreulicke/feature/suggested-fix
Browse files Browse the repository at this point in the history
Support suggested fix
  • Loading branch information
ssgreg committed Aug 18, 2020
2 parents facb4e6 + 904b2a1 commit 5ded3fb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/nlreturn/nlreturn.go
@@ -1,6 +1,7 @@
package nlreturn

import (
"fmt"
"go/ast"
"go/token"

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

if line(pass, stmt.Pos())-line(pass, block[i-1].End()) <= 1 {
pass.Reportf(stmt.Pos(), "%s with no blank line before", name(stmt))
pass.Report(analysis.Diagnostic{
Pos: stmt.Pos(),
Message: fmt.Sprintf("%s with no blank line before", name(stmt)),
SuggestedFixes: []analysis.SuggestedFix{
{
TextEdits: []analysis.TextEdit{
{
Pos: stmt.Pos(),
NewText: []byte("\n"),
End: stmt.Pos(),
},
},
},
},
})
}
}
}
Expand Down

0 comments on commit 5ded3fb

Please sign in to comment.