aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/linters.go
Commit message (Collapse)AuthorAgeFilesLines
* linters: avoid crash when analyzing function callRobin Jarry2023-11-021-19/+50
| | | | | | | | | | | | | | | | | | | | | When encountering a statement such as: go functionName() The identifier is not a local symbol but should be looked up in the current package. Do not consider that all these statements will refer to local variables. The only way to do this is to run a second analyzer that depends on the first one. Store all unresolved methods and functions into a indirectCalls struct. Reuse that result in the second analyzer to resolve the function declarations and check their bodies for the defer log.PanicHandler() statement. Fix one newly reported issues. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* contrib: add linter to check for panic handler in goroutinesRobin Jarry2023-01-061-0/+128
If log.PanicHandler() is not installed in a goroutine and a panic occurs, the terminal state is not restored. This causes the panic trace to be unreadable since the terminal is broken. Add a custom analyzer that parses our code and ensures that: defer log.PanicHandler() is the first statement of all functions that are executed in goroutines. Include that linter in golangci config. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>