There exists many duplicated code， why not refactoring？It seems that in each checker, the desitination is always a BasicLit, and before find a BasicLit, there are codes duplicated.
you're totally right!
This linter is mainly the result of trying out the go/analysis API some years ago. Since then I had multiple times in the past the idea/wish to rewrite it completely in a v2 and use an analyser like in gosec or similar tools.
But to be honest this project has not my main focus. So don't get me wrong. I will of course fix bugs and false-positives when they pop up. But I've no time for a complete rewrite.
Currently when you define a time duration with a number it is considered a magic number.
timeToWaitForTask := 30 * time.Second
I would think this qualifies as not being a magic number since it is clear what you are using the number for. It also reads better than the desired state which would be this.
timeInSecondsToWait := 30 timetoWaitForTask := timeInSecondsToWait * time.Second
in general I share totally the same point that @bflad brought up. But on the other side I can also understand that, especially in smaller projects, time related findings looking weird because it's very common to write timeouts inline. So I tried the last 3 evenings to filter them out via a new flag "time-sensitive" yes/no.
But unfortunately it's harder than I thought in the beginning and I ended up with some partly very complex code that also shows some false-positives during my tests and even more bad with an operation checker who also jumps in for assignments.
So maybe it's me and the lack of time but I'll break up here to prevent some strange results in the future.
Become curious: should any number (within consition
2 <= n <= 36) be considered as magic number if used in