Skip to content

Fix remaining cpplint issues: C-style casts and missing includes - #475

Merged
hendrikmuhs merged 1 commit into
KeyviDev:masterfrom
hendrikmuhs:fix-cpp-lint-2
Oct 21, 2026
Merged

hendrikmuhs merged 1 commit into
KeyviDev:masterfrom
hendrikmuhs:fix-cpp-lint-2

Conversation

@hendrikmuhs

Copy link
Copy Markdown
Contributor

final pre-commit fixes for pre-commit -a

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 24. Check the log or trigger a new build to see more.

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

      return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];
             ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];
                                                                        ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];
                                                     ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "uint16_t" is directly included [misc-include-cleaner]

keyvi/include/keyvi/compression/predictive_compression.h:29:

- #include <cstdio>
+ #include <cstdint>
+ #include <cstdio>

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

      return predictor_table_[(static_cast<uint16_t>(bigram[0]) << 8) + bigram[1]];
                                                                   ^

instream.get(c);
if (instream.eof()) break;
uint16_t index = (uint16_t(c) << 8) + (uint16_t)instream.get();
uint16_t index = (static_cast<uint16_t>(c) << 8) + static_cast<uint16_t>(instream.get());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

      uint16_t index = (static_cast<uint16_t>(c) << 8) + static_cast<uint16_t>(instream.get());
                                                    ^

instream.get(c);
if (instream.eof()) break;
uint16_t index = (uint16_t(c) << 8) + (uint16_t)instream.get();
uint16_t index = (static_cast<uint16_t>(c) << 8) + static_cast<uint16_t>(instream.get());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'index' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness]

Suggested change
uint16_t index = (static_cast<uint16_t>(c) << 8) + static_cast<uint16_t>(instream.get());
uint16_t const index = (static_cast<uint16_t>(c) << 8) + static_cast<uint16_t>(instream.get());

#include <array>
#include <limits>
#include <utility>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: included header utility is not used directly [misc-include-cleaner]

Suggested change

* @param bit the bit to set.
*/
inline void Set(const size_t bit) { bits_[bit >> 6] |= (uint64_t)1 << (bit & 63); }
inline void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'Set' has inline specifier but is implicitly inlined [readability-redundant-inline-specifier]

Suggested change
inline void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }
void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }

* @param bit the bit to set.
*/
inline void Set(const size_t bit) { bits_[bit >> 6] |= (uint64_t)1 << (bit & 63); }
inline void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "size_t" is directly included [misc-include-cleaner]

  inline void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }
                        ^

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 16. Check the log or trigger a new build to see more.

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];
             ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];
                                                                        ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];
                                                     ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8) + bigram[1]];
                                                                   ^

instream.get(c);
if (instream.eof()) break;
uint16_t index = (uint16_t(c) << 8) + (uint16_t)instream.get();
const uint16_t index = ((static_cast<unsigned>(c) & 0xFFu) << 8) + instream.get();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
const uint16_t index = ((static_cast<unsigned>(c) & 0xFFu) << 8) + instream.get();
const uint16_t index = ((static_cast<unsigned>(c) & 0xFFU) << 8) + instream.get();

instream.get(c);
if (instream.eof()) break;
uint16_t index = (uint16_t(c) << 8) + (uint16_t)instream.get();
const uint16_t index = ((static_cast<unsigned>(c) & 0xFFu) << 8) + instream.get();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

      const uint16_t index = ((static_cast<unsigned>(c) & 0xFFu) << 8) + instream.get();
                                                                    ^

* @param bit the bit to set.
*/
inline void Set(const size_t bit) { bits_[bit >> 6] |= (uint64_t)1 << (bit & 63); }
void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

  void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }
                                                                                     ^

* @param bit the bit to set.
*/
inline void Set(const size_t bit) { bits_[bit >> 6] |= (uint64_t)1 << (bit & 63); }
void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

  void Set(const size_t bit) { bits_[bit >> 6] |= static_cast<uint64_t>(1) << (bit & 63); }
                                            ^

* @param bit the bit to erase.
*/
inline void Erase(const size_t bit) { bits_[bit >> 6] &= (uint64_t)(~(1 << (bit & 63))); }
void Erase(const size_t bit) { bits_[bit >> 6] &= static_cast<uint64_t>(~(1ULL << (bit & 63))); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

  void Erase(const size_t bit) { bits_[bit >> 6] &= static_cast<uint64_t>(~(1ULL << (bit & 63))); }
                                                                                           ^

* @param bit the bit to erase.
*/
inline void Erase(const size_t bit) { bits_[bit >> 6] &= (uint64_t)(~(1 << (bit & 63))); }
void Erase(const size_t bit) { bits_[bit >> 6] &= static_cast<uint64_t>(~(1ULL << (bit & 63))); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]

  void Erase(const size_t bit) { bits_[bit >> 6] &= static_cast<uint64_t>(~(1ULL << (bit & 63))); }
                                              ^

@hendrikmuhs
hendrikmuhs force-pushed the fix-cpp-lint-2 branch 2 times, most recently from 7a43caf to b0744bb Compare October 20, 2026 20:29

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 10 out of 19. Check the log or trigger a new build to see more.

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];
             ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];
                                                                         ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];
                                                     ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8u) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]];

instream.get(c);
if (instream.eof()) break;
uint16_t index = (uint16_t(c) << 8) + (uint16_t)instream.get();
const uint16_t index = ((static_cast<unsigned>(c) & 0xFFU) << 8u) + instream.get();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
const uint16_t index = ((static_cast<unsigned>(c) & 0xFFU) << 8u) + instream.get();
const uint16_t index = ((static_cast<unsigned>(c) & 0xFFU) << 8U) + instream.get();

* @param bit the bit to set.
*/
inline void Set(const size_t bit) { bits_[bit >> 6] |= (uint64_t)1 << (bit & 63); }
void Set(const size_t bit) { bits_[bit >> 6u] |= static_cast<uint64_t>(1) << (bit & 63u); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
void Set(const size_t bit) { bits_[bit >> 6u] |= static_cast<uint64_t>(1) << (bit & 63u); }
void Set(const size_t bit) { bits_[bit >> 6U] |= static_cast<uint64_t>(1) << (bit & 63u); }

* @param bit the bit to set.
*/
inline void Set(const size_t bit) { bits_[bit >> 6] |= (uint64_t)1 << (bit & 63); }
void Set(const size_t bit) { bits_[bit >> 6u] |= static_cast<uint64_t>(1) << (bit & 63u); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
void Set(const size_t bit) { bits_[bit >> 6u] |= static_cast<uint64_t>(1) << (bit & 63u); }
void Set(const size_t bit) { bits_[bit >> 6u] |= static_cast<uint64_t>(1) << (bit & 63U); }

* @param bit the bit to erase.
*/
inline void Erase(const size_t bit) { bits_[bit >> 6] &= (uint64_t)(~(1 << (bit & 63))); }
void Erase(const size_t bit) { bits_[bit >> 6u] &= static_cast<uint64_t>(~(1ULL << (bit & 63u))); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
void Erase(const size_t bit) { bits_[bit >> 6u] &= static_cast<uint64_t>(~(1ULL << (bit & 63u))); }
void Erase(const size_t bit) { bits_[bit >> 6U] &= static_cast<uint64_t>(~(1ULL << (bit & 63u))); }

* @param bit the bit to erase.
*/
inline void Erase(const size_t bit) { bits_[bit >> 6] &= (uint64_t)(~(1 << (bit & 63))); }
void Erase(const size_t bit) { bits_[bit >> 6u] &= static_cast<uint64_t>(~(1ULL << (bit & 63u))); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
void Erase(const size_t bit) { bits_[bit >> 6u] &= static_cast<uint64_t>(~(1ULL << (bit & 63u))); }
void Erase(const size_t bit) { bits_[bit >> 6u] &= static_cast<uint64_t>(~(1ULL << (bit & 63U))); }

*/
inline bool Get(const size_t bit) const { return (bits_[bit >> 6] & ((uint64_t)1 << (bit & 63))) != 0; }
[[nodiscard]] bool Get(const size_t bit) const {
return (bits_[bit >> 6u] & (static_cast<uint64_t>(1) << (bit & 63u))) != 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
return (bits_[bit >> 6u] & (static_cast<uint64_t>(1) << (bit & 63u))) != 0;
return (bits_[bit >> 6U] & (static_cast<uint64_t>(1) << (bit & 63u))) != 0;

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

*/
inline bool Get(const size_t bit) const { return (bits_[bit >> 6] & ((uint64_t)1 << (bit & 63))) != 0; }
[[nodiscard]] bool Get(const size_t bit) const {
return (bits_[bit >> 6u] & (static_cast<uint64_t>(1) << (bit & 63u))) != 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
return (bits_[bit >> 6u] & (static_cast<uint64_t>(1) << (bit & 63u))) != 0;
return (bits_[bit >> 6u] & (static_cast<uint64_t>(1) << (bit & 63U))) != 0;

PackedState() : PackedState(0, 0, 0) {}
PackedState(OffsetTypeT offset, HashCodeTypeT hashcode, int num_outgoing)
: offset_(offset), hashcode_(hashcode), num_outgoing_and_cookie_((uint32_t)(num_outgoing & 0x1FF)) {}
: offset_(offset), hashcode_(hashcode), num_outgoing_and_cookie_(static_cast<uint32_t>(num_outgoing) & 0x1FFu) {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
: offset_(offset), hashcode_(hashcode), num_outgoing_and_cookie_(static_cast<uint32_t>(num_outgoing) & 0x1FFu) {}
: offset_(offset), hashcode_(hashcode), num_outgoing_and_cookie_(static_cast<uint32_t>(num_outgoing) & 0x1FFU) {}

HashCodeTypeT GetHashcode() const { return hashcode_; }

int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FF); }
int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'GetNumberOfOutgoingTransitions' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }
[[nodiscard]] int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }

HashCodeTypeT GetHashcode() const { return hashcode_; }

int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FF); }
int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }
int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFU); }

int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }

int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00) >> 9); }
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9u); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'GetCookie' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9u); }
[[nodiscard]] int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9u); }

int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }

int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00) >> 9); }
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9u); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9u); }
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00U) >> 9u); }

int GetNumberOfOutgoingTransitions() const { return static_cast<int>(this->num_outgoing_and_cookie_ & 0x1FFu); }

int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00) >> 9); }
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9u); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9u); }
int GetCookie() const { return static_cast<int>((this->num_outgoing_and_cookie_ & 0xFFFFFE00u) >> 9U); }


void SetCookie(int value) {
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FF) | (uint32_t)(value << 9);
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FFu) | (static_cast<uint32_t>(value) << 9u);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FFu) | (static_cast<uint32_t>(value) << 9u);
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FFU) | (static_cast<uint32_t>(value) << 9u);


void SetCookie(int value) {
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FF) | (uint32_t)(value << 9);
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FFu) | (static_cast<uint32_t>(value) << 9u);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: integer literal has suffix 'u', which is not uppercase [hicpp-uppercase-literal-suffix]

Suggested change
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FFu) | (static_cast<uint32_t>(value) << 9u);
this->num_outgoing_and_cookie_ = (this->num_outgoing_and_cookie_ & 0x1FFu) | (static_cast<uint32_t>(value) << 9U);

#define KEYVI_DICTIONARY_FSA_INTERNAL_SPARSE_ARRAY_BUILDER_H_

#include <iostream> // NOLINT(misc-include-cleaner)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: included header iostream is not used directly [misc-include-cleaner]

Suggested change

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use array subscript when the index is not an integer constant expression [cppcoreguidelines-pro-bounds-constant-array-index]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]];
             ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]];
                                                                         ^

return "";
} else {
return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]];
return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]

      return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]];
                                                     ^

@hendrikmuhs
hendrikmuhs merged commit 7e5f5a9 into KeyviDev:master Oct 21, 2026
23 of 24 checks passed
@hendrikmuhs
hendrikmuhs deleted the fix-cpp-lint-2 branch October 21, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant