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

support map index match #360

Closed
peakle opened this issue Jan 16, 2022 · 2 comments
Closed

support map index match #360

peakle opened this issue Jan 16, 2022 · 2 comments

Comments

@peakle
Copy link
Contributor

peakle commented Jan 16, 2022

rule:

	m.Match(`$_{$*_, $_: strings.Compare($s1, $_), $*_}`,
		`$_{$*_, strings.Compare($s1, $_): $_, $*_}`).
		Report(`don't use strings.Compare on hot path, change it to built-in operators`).
		At(m["s1"])

test data:

func f() {
	_ = map[int]int{
		// doesn't match this 
		strings.Compare("", ""): 0,
	}
}

quasilyte added a commit that referenced this issue Jan 16, 2022
@quasilyte
Copy link
Owner

It looks like tests are passing:
#361

Is there any extra context that should be taken into account to reproduce this issue?

@peakle
Copy link
Contributor Author

peakle commented Jan 16, 2022

i tested it on gocritic master on this commit, maybe it related to dependecies version
https://github.com/go-critic/go-critic/tree/319a0d4b91da874eb6f0cdbbf57f8669a0ac13c6

quasilyte added a commit that referenced this issue Jan 18, 2022
@peakle peakle closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants