You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
staticcheck is a pretty awesome static analysis tool. It covers a wide variety of checks from simplification, missed error checks, overshadowed variables, etc... and it's also very configurable which means you can ignore lints you dont like.
In particular the lints for missed error checks, overshadowed variables, defers before error checks, are pretty useful. From my own experience it seems to lead to a healthier code base, and has identified on more than one occasion logic that would in edge cases cause bugs, as well as helping to figure out why a test was passing that shouldn't.
Implementing them in all repositories is certainly a bit excessive, but the great thing about staticcheck is that it can be implemented without any disruptions or needing to consider breaking changes.
Starting to get pretty sleepy as I write this so I'll show a couple of the "superficial" lints performed.
staticcheck is a pretty awesome static analysis tool. It covers a wide variety of checks from simplification, missed error checks, overshadowed variables, etc... and it's also very configurable which means you can ignore lints you dont like.
In particular the lints for missed error checks, overshadowed variables, defers before error checks, are pretty useful. From my own experience it seems to lead to a healthier code base, and has identified on more than one occasion logic that would in edge cases cause bugs, as well as helping to figure out why a test was passing that shouldn't.
Implementing them in all repositories is certainly a bit excessive, but the great thing about staticcheck is that it can be implemented without any disruptions or needing to consider breaking changes.
Starting to get pretty sleepy as I write this so I'll show a couple of the "superficial" lints performed.
Which could be changed to
Now in this particular case whether this is an improvement is ultimately up to you. It can also catch things like:
Which can be simplified into:
The text was updated successfully, but these errors were encountered: