Skip to content

Commit

Permalink
Add NOLINT to use of operator[]
Browse files Browse the repository at this point in the history
We already check the bounds so the cpp core guideline presumably
does not apply and we don't want to pay the price for the additional
bounds check inside at().
  • Loading branch information
travisdowns committed Jul 14, 2022
1 parent f649f7f commit fd6353f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/v/kafka/server/handlers/handler_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ constexpr auto make_lut(type_list<Ts...>) {
std::optional<handler> handler_for_key(kafka::api_key key) noexcept {
static constexpr auto lut = make_lut(request_types{});
if (key >= (short)0 && key < (short)lut.size()) {
// We have already checked the bounds above so it is safe to use []
// instead of at()
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index)
if (auto handler = lut[key]) {
return handler;
}
Expand Down

0 comments on commit fd6353f

Please sign in to comment.