mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 07:58:22 -05:00
Add static analyzer to discourage use of panic() (#15075)
* Implement static analysis to prevent panics * Add nopanic to nogo * Fix violations and add exclusions Fix violations and add exclusions for all * Changelog fragment * Use pass.Report instead of pass.Reportf * Remove strings.ToLower for checking init method name * Add exclusion for herumi init * Move api/client/beacon template function to init and its own file * Fix nopanic testcase
This commit is contained in:
4
cache/lru/lru_wrpr.go
vendored
4
cache/lru/lru_wrpr.go
vendored
@@ -10,7 +10,7 @@ import (
|
||||
func New(size int) *lru.Cache {
|
||||
cache, err := lru.New(size)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("lru new failed: %w", err))
|
||||
panic(fmt.Errorf("lru new failed: %w", err)) // lint:nopanic -- This should never panic.
|
||||
}
|
||||
return cache
|
||||
}
|
||||
@@ -20,7 +20,7 @@ func New(size int) *lru.Cache {
|
||||
func NewWithEvict(size int, onEvicted func(key interface{}, value interface{})) *lru.Cache {
|
||||
cache, err := lru.NewWithEvict(size, onEvicted)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("lru new with evict failed: %w", err))
|
||||
panic(fmt.Errorf("lru new with evict failed: %w", err)) // lint:nopanic -- This should never panic.
|
||||
}
|
||||
return cache
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user