mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -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:
@@ -35,7 +35,7 @@ func (f fieldType) Size() int {
|
||||
case typeBytes4:
|
||||
return 4
|
||||
default:
|
||||
panic("can't determine size for unrecognizedtype ")
|
||||
panic("can't determine size for unrecognizedtype ") // lint:nopanic -- Impossible field type.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +68,10 @@ func Depth(v uint64) (out uint8) {
|
||||
}
|
||||
|
||||
// Merkleize with log(N) space allocation
|
||||
// This method will panic when count > limit.
|
||||
func Merkleize(hasher Hasher, count, limit uint64, leaf func(i uint64) []byte) (out [32]byte) {
|
||||
if count > limit {
|
||||
panic("merkleizing list that is too large, over limit")
|
||||
panic("merkleizing list that is too large, over limit") // lint:nopanic -- Panic is communicated in godoc commentary.
|
||||
}
|
||||
if limit == 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user