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

SA1013: overhaul check #1213

Closed
dominikh opened this issue Mar 24, 2022 · 1 comment
Closed

SA1013: overhaul check #1213

dominikh opened this issue Mar 24, 2022 · 1 comment

Comments

@dominikh
Copy link
Owner

False positives

We should make sure that we're actually calling io.Seeker.Seek, and not some other method named Seek, to avoid false positives like

type S struct{}

func (S) Seek(int, string)

func fn1() {
	var s S
	s.Seek(io.SeekStart, "")
}

In fact we even look at package-level functions in other packages, not just methods.

Furthermore, we look for the use of io.SeekStart etc, without making sure that this refers to a package level constant or the actual stdlib io package.

False negatives

We only look for the io.Seek* constants, not the deprecated os equivalents.

@dominikh
Copy link
Owner Author

We only look for the io.Seek* constants, not the deprecated os equivalents.

This isn't actually a problem, because the os equivalents have types, and can't actually be used in the wrong order (not without explicit conversions, anyway).

dominikh added a commit that referenced this issue Apr 25, 2022
dominikh added a commit that referenced this issue Apr 25, 2022
dominikh added a commit that referenced this issue May 16, 2022
Updates gh-1213

(cherry picked from commit 3f103b8)
dominikh added a commit that referenced this issue May 16, 2022
dominikh added a commit that referenced this issue May 16, 2022
Updates gh-1213

(cherry picked from commit 3f103b8)
dominikh added a commit that referenced this issue May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant