Repository navigation
Fix remaining cpplint issues: C-style casts and missing includes #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,8 @@ | |
|
|
||
| #include <inttypes.h> | ||
| #include <bitset> | ||
| #include <cstdint> | ||
| #include <cstdio> | ||
| #include <fstream> | ||
| #include <iostream> | ||
| #include <sstream> | ||
|
|
@@ -58,7 +60,7 @@ class PredictiveCompression final { | |
| if (bigram[0] == 0 || bigram[1] == 0) { | ||
| return ""; | ||
| } else { | ||
| return predictor_table_[(uint16_t(bigram[0]) << 8) + bigram[1]]; | ||
| return predictor_table_[(static_cast<unsigned>(bigram[0]) << 8U) + bigram[1]]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]];
^
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]];
^ |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -210,7 +212,7 @@ class PredictiveCompression final { | |
| char c; | ||
| 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(); | ||
| uint8_t length = instream.get(); | ||
| if (length > 8) { | ||
| char error[100]; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -27,7 +27,10 @@ | |||
|
|
||||
| #include <algorithm> | ||||
| #include <array> | ||||
| #include <cstddef> | ||||
| #include <cstdint> | ||||
| #include <limits> | ||||
| #include <utility> | ||||
|
|
||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||
| namespace keyvi { | ||||
| namespace dictionary { | ||||
|
|
@@ -63,7 +66,7 @@ struct BitVector final { | |||
| * Sets a bit in the bitvector. | ||||
| * @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); } | ||||
|
|
||||
| /** | ||||
| * Sets all bits of the given bitvector | ||||
|
|
@@ -81,7 +84,7 @@ struct BitVector final { | |||
| bits_[byte_position + i] |= other.bits_[i]; | ||||
| } | ||||
| } else { | ||||
| bits_[byte_position] |= ((uint64_t)other.bits_[0] << bit_position); | ||||
| bits_[byte_position] |= (static_cast<uint64_t>(other.bits_[0]) << bit_position); | ||||
| for (size_t i = 1; i < write_length; ++i) { | ||||
| bits_[byte_position + i] |= ((other.bits_[i] << bit_position) | (other.bits_[i - 1] >> (64 - bit_position))); | ||||
| } | ||||
|
|
@@ -112,14 +115,16 @@ struct BitVector final { | |||
| * Erase a bit, set it to 0. | ||||
| * @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))); } | ||||
|
|
||||
| /** Gets the state of the given bit | ||||
| * | ||||
| * @param bit the bit | ||||
| * @return True if set, false otherwise. | ||||
| */ | ||||
| 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; | ||||
| } | ||||
|
|
||||
| /** | ||||
| * Get the next non set bit in the bitvector starting from the given position. | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -25,6 +25,8 @@ | |||
| #ifndef KEYVI_DICTIONARY_FSA_INTERNAL_SPARSE_ARRAY_BUILDER_H_ | ||||
| #define KEYVI_DICTIONARY_FSA_INTERNAL_SPARSE_ARRAY_BUILDER_H_ | ||||
|
|
||||
| #include <iostream> // NOLINT(misc-include-cleaner) | ||||
|
|
||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||
| #include "keyvi/dictionary/fsa/internal/constants.h" | ||||
| #include "keyvi/dictionary/fsa/internal/lru_generation_cache.h" | ||||
| #include "keyvi/dictionary/fsa/internal/minimization_hash.h" | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| // | ||
|
|
||
| #include <cstdio> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include <boost/test/unit_test.hpp> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ | |
| */ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include <boost/test/unit_test.hpp> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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]