-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Remove the "always receives X" check entirely #31
Comments
I don't like it too |
I don't remember the last time I've seen it. I might've fixed all instances and not introduced new ones. As a result, it's hard for me to say, but it sounds useful.
I do not. |
It is. annoying. |
I think I remember a couple of times where this check improved my code. They were mostly cases arising after refactorings, when boolean (or constant) flags of functions or methods become always-true or always-false after some removals and code moves. I can also see it potentially preventing bugs where you add such flag, add it to an old function call, copy-paste that call into a new location, and forget to switch the flag. For me personally it would be a pity to lose this check. |
The results so far are pretty much 50/50. Usually, that would mean that the check isn't generally useful, as I try to keep my linters as precise as possible. Having said that, something has changed recently - gopls will start supporting different severities depending on the analyzer. So, when refactoring unparam to use go/analysis (which I need to do anyway), I can split up the tool into multiple analyzers:
So I think we can keep all the features, while ensuring that the "error severity" has a far lower false positive rate. |
We're using this linter through |
@mitranim it's not configurable right now. |
This is the reason why I had the disable the (otherwise useful) I disagree with the premise of this linter: sometimes it's simply better style to pass a value as an argument, even if it's always the same. |
It'd be nice to have a way to disable a feature if it's annoying so many folks. |
I get this argument and it may be a good compromise to limit this check to booleans only. |
I think detection is a good feature, but I also think it is excessive. I think it should at least be an option. I can't even implement it to CI because of this. |
I'd like to be able to disable the check for "parameter/result X is always value Y" as well. As mentioned before, it can be useful to declare parameters that are constant now but might be variable in the future. It makes a function more generic and easier to understand |
We made it more conservative in #14, but it's still prone to false positives.
I've gone through all the warnings from this linter that I have applied, and this kind were almost non-existent.
Does anyone find it useful? Does anyone find it annoying? Input welcome.
The text was updated successfully, but these errors were encountered: