Skip to content

Relax S1008 when branches contain documentation #704

@dominikh

Description

@dominikh

Spotted in tailscale/tailscale@bd0e20f:

func preferGoResolver() bool {
	//lint:ignore S1008 disagree; prefer comments

	// There does not appear to be a local resolver running
	// on iOS, and NetworkExtension is good at isolating DNS.
	// So do not use the Go resolver on macOS/iOS.
	if runtime.GOOS == "darwin" {
		return false
	}
	// Otherwise, the Go resolver is fine and slightly preferred
	// since it's lighter, not using cgo calls & threads.
	return true
}

We should not suggest replacing this with return runtime.GOOS != "darwin".
When we fix this, we should handle both comments that are attached to the IfStmt as well as comments attached to the ReturnStmt (and probably loose comments inside the block, too, but hopefully that's less common…)

/cc @bradfitz – you have to yell at me when staticcheck is being wrong :-)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions