kisielk / errcheck

errcheck checks that you checked errors.
MIT License
2.33k stars 138 forks source link

Calculate correct position with comments before the package keyword #215

Closed rmohr closed 2 years ago

rmohr commented 2 years ago

Detect the file beginning by using pass.Fset.File(f.Pos()) instead of assuming that f.Pos() is always the beginning of the file.

f.Pos() is the position of the package keyword which does not always correlate with the beginning of the file. f.Pos() is not the beginning of the file when there is for instance a comment before the package, which can lead to wrong reportings of the actual error position.

rmohr commented 2 years ago

@maiqueb FYI

rmohr commented 2 years ago

@kisielk thanks for maintaining this great linter.

kisielk commented 2 years ago

Looks good to me, can't believe it's been unreported for so long :)

maiqueb commented 2 years ago

@kisielk would you be willing to create a release container this fix ?

We're keen on it for https://github.com/kubevirt/kubevirt/pull/8058

kisielk commented 2 years ago

@maiqueb I just created v1.6.2 which contains the fix. Thanks

maiqueb commented 2 years ago

@maiqueb I just created v1.6.2 which contains the fix. Thanks

Thank you :) Highly appreciated.