Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use comment.Maps.IgnorePos() instead of IgnoreLine() #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions nilerr.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ func run(pass *analysis.Pass) (interface{}, error) {

reportFail := func(v ssa.Value, ret *ssa.Return, format string) {
pos := ret.Pos()
line := getNodeLineNumber(pass, ret)
errLines := getValueLineNumbers(pass, v)
if !cmaps.IgnoreLine(pass.Fset, line, "nilerr") {
if !cmaps.IgnorePos(pos, "nilerr") {
var errLineText string
if len(errLines) == 1 {
errLineText = fmt.Sprintf("line %d", errLines[0])
Expand Down Expand Up @@ -83,11 +82,6 @@ func getValueLineNumbers(pass *analysis.Pass, v ssa.Value) []int {
return []int{pass.Fset.File(pos).Line(pos)}
}

func getNodeLineNumber(pass *analysis.Pass, node ssa.Node) int {
pos := node.Pos()
return pass.Fset.File(pos).Line(pos)
}

var errType = types.Universe.Lookup("error").Type().Underlying().(*types.Interface)

func binOpErrNil(b *ssa.BasicBlock, op token.Token) ssa.Value {
Expand Down