refactor: clarify printf-like message to exclude all format specifiers - #96
refactor: clarify printf-like message to exclude all format specifiers#96scop wants to merge 1 commit into
Conversation
07cd458 to
7c99273
Compare
The previous wording can raise questions and false assumptions that _some_ format specifiers would be ok, but none actually are.
7c99273 to
36cbd64
Compare
|
|
||
| log.Info("%[3]*s x") // want `logging message should not use format specifier ".+"` | ||
| log.Info("%[3]d x") // want `logging message should not use format specifier ".+"` | ||
| log.Info("%[3]*s x") // want `logging message should not contain format specifiers, found ".+"` |
There was a problem hiding this comment.
My comment is not on what you changed, but on what was reported here
%[3]s leads to .+ ?
It's something that come from the external lib code imported from golang.org/x/tool but it's unclear to me what it could mean.
Do you?
There was a problem hiding this comment.
I guess but have not verified at all, that the line could have been written as this instead:
log.Info("%[3]*s x") // want `logging message should not contain format specifiers, found "%\[3\]\*s"`So I guess the "want" comment "argument" strings in backticks are actually regular expressions, and because the specifier %[3]*s contains a few regular expression metacharacters, they would need escaping if it was written literally.
Instead, matching it with simply .+ could have been seen good enough by the original author. Or maybe there was some problem with metacharacter escaping, I don't know (nor do I know if a simple backslash would do the trick or if something else would be required).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #96 +/- ##
=======================================
Coverage 98.79% 98.79%
=======================================
Files 13 13
Lines 582 582
=======================================
Hits 575 575
Misses 5 5
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The previous wording can raise questions and false assumptions that some format specifiers would be ok, but none actually are.