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
staticcheck doesn't know about my enumer #660
Comments
I think it's an issue with var _DayNameToValueMap = map[string]Day{
_DayName[0:6]: 0,
_DayName[6:13]: 1,
_DayName[13:22]: 2,
_DayName[22:30]: 3,
_DayName[30:36]: 4,
_DayName[36:44]: 5,
_DayName[44:50]: 6,
} Instead of: var _DayNameToValueMap = map[string]Day{
_DayName[0:6]: Monday,
_DayName[6:13]: Tuesday,
_DayName[13:22]: Wednesday,
_DayName[22:30]: Thursday,
_DayName[30:36]: Friday,
_DayName[36:44]: Saturday,
_DayName[44:50]: Sunday,
} I don't know why the authors of the tool decided to use raw numbers. |
I'm inclined to agree with Ainar. The original |
Thinking about it, though, it occurs to me that it's plausible to imagine a use case where it's practical to just omit the constant entirely; for instance, consider
|
I am going to close this issue as WAI. Note that only one constant from the group of constants needs to be used to mark the entire group as used. If neither you nor the tool uses any of the constants, one must wonder why the constants are being generated at all. In this specific case, it should be on the tool to actually use the constants. |
2019.2.3
The generated code is pretty straightforward -- it translates "YMDH" to 3.
Note that the sequence
timeQuantumYMDH
, while "unused", is affecting the behavior of the program in the expected manner.I honestly don't have any clue how this could be reasonably detected and I should probably just use a linter comment but I feel like the stringer-type cases are just common enough to be worth bringing up. (
enumer
is a fork of stringer that, well. Does this.)The text was updated successfully, but these errors were encountered: