menu
manual-saturating-arithmetic
Prefer saturating arithmetic over equivalent manual bounds logic
Falling back from checked unsigned arithmetic to the matching integer bound manually implements saturation. Instead, you SHOULD call the corresponding saturating arithmetic method.
Reported
1function add(left: uint32, right: uint32): uint32 {2 return left.checkedAdd(right) ?? uint32.maximum();3}Accepted
1function add(left: uint32, right: uint32): uint32 {2 return left.saturatingAdd(right);3}