Skip to content

Commit 8821107

Browse files
authored
fix: ignore cgo files (#167)
1 parent 9ab31fc commit 8821107

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

analyzer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ func (wa *wslAnalyzer) run(pass *analysis.Pass) (any, error) {
8686
continue
8787
}
8888

89-
// if the file is related to cgo the filename of the unadjusted position is a not a '.go' file.
9089
fn := pass.Fset.PositionFor(file.Pos(), false).Filename
9190

91+
// if the file is related to cgo the filename of the unadjusted position is a not a '.go' file.
92+
if !strings.HasSuffix(fn, ".go") {
93+
continue
94+
}
95+
9296
// The file is skipped if the "unadjusted" file is a Go file, and it's a generated file (ex: "_test.go" file).
9397
// The other non-Go files are skipped by the first 'if' with the adjusted position.
9498
if !wa.config.IncludeGenerated && ast.IsGenerated(file) && strings.HasSuffix(fn, ".go") {

testdata/src/default_config/cgo/cgo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ func _() {
2222

2323
func Advanced() {
2424
var foo = 1
25-
var bar = 2 // want "declarations should never be cuddled"
26-
var biz int // want "declarations should never be cuddled"
25+
var bar = 2
26+
var biz int
2727

2828
x := []string{}
2929
x = append(x, "literal")
3030
notUsed := "just assigning, don't mind me"
31-
x = append(x, "not z..") // want "append only allowed to cuddle with appended value"
31+
x = append(x, "not z..")
3232
useMe := "right away"
3333
alsoNotUsed := ":("
34-
x = append(x, "just noise") // want "append only allowed to cuddle with appended value"
34+
x = append(x, "just noise")
3535
x = append(x, useMe)
3636

3737
_ = foo

0 commit comments

Comments
 (0)