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

Suggest incorrectly substitutes variables that have more than one character #128

Closed
sebastien-rosset opened this issue Nov 13, 2020 · 2 comments

Comments

@sebastien-rosset
Copy link
Contributor

sebastien-rosset commented Nov 13, 2020

With the rule below:

	m.Match(`$x.$f($fmt, $e)`).
		Suggest(`$x.$f($fmt, zap.Error($e))`)

If the code is:

logger.Sugar().Errorf("error: %v", err)

Then the suggestion will be slightly incorrect:

suggestion: logger.Sugar().Errorf(Errorfmt, zap.Error(err))

The rule works if the $fmt variable is replaced with a variable that has one character, such as $y:

	m.Match(`$x.$f($y, $e)`).
		Suggest(`$x.$f($y, zap.Error($e))`)

In that case the suggestion will be correct:

suggestion: logger.Sugar().Errorf("error: %v", zap.Error(err))
@quasilyte
Copy link
Owner

Interesting! I though that I fixed this in #123.
Have you tried the latest version?
I probably need to make a new release and attach compiled binaries there...

@sebastien-rosset
Copy link
Contributor Author

Ah yes, it's fixed in the latest version of ruleguard. I think it's because I was using golangci, which hadn't bumped the version to the latest. I am closing this issue.

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