diff --git a/.github/workflows/clang-tidy-post.yml b/.github/workflows/clang-tidy-post.yml index 1cbece053..cd827ac4b 100644 --- a/.github/workflows/clang-tidy-post.yml +++ b/.github/workflows/clang-tidy-post.yml @@ -19,3 +19,4 @@ jobs: lgtm_comment_body: '' annotations: false max_comments: 10 + num_comments_as_exitcode: false diff --git a/.github/workflows/clang-tidy-review.yml b/.github/workflows/clang-tidy-review.yml new file mode 100644 index 000000000..9d5e28739 --- /dev/null +++ b/.github/workflows/clang-tidy-review.yml @@ -0,0 +1,29 @@ +name: clang-tidy-review + +# Runs clang-tidy on the changed files and uploads the result as artifact +# clang-tidy-post takes the artifact and posts the comments +on: + pull_request: + paths: ['**.cpp', '**.h', '**.hpp', '**CMakeLists.txt', '**.cmake', '.github/workflows/clang*.yml', '**.clang-tidy'] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - uses: ZedThree/clang-tidy-review@v0.21.0 + id: review + with: + split_workflow: true + build_dir: build + apt_packages: "libsnappy-dev, libzzip-dev, zlib1g-dev, libboost-all-dev, libzstd-dev" + clang_tidy_checks: '' + cmake_command: "cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ." + + - uses: ZedThree/clang-tidy-review/upload@v0.21.0 + + # If there are any comments, fail the check + - if: steps.review.outputs.total_comments > 0 + run: exit 1 diff --git a/keyvi/include/keyvi/dictionary/fsa/automata.h b/keyvi/include/keyvi/dictionary/fsa/automata.h index 7a4a94b28..12feca7cd 100644 --- a/keyvi/include/keyvi/dictionary/fsa/automata.h +++ b/keyvi/include/keyvi/dictionary/fsa/automata.h @@ -406,17 +406,11 @@ class Automata final { return value_store_reader_->GetMsgPackedValueAsString(state_value, compression_algorithm); } - std::string GetStatistics() const { - return dictionary_properties_->GetStatistics(); - } + [[nodiscard]] std::string GetStatistics() const { return dictionary_properties_->GetStatistics(); } - const std::string& GetManifest() const { - return dictionary_properties_->GetManifest(); - } + [[nodiscard]] const std::string& GetManifest() const { return dictionary_properties_->GetManifest(); } - const uint64_t GetVersion() const { - return dictionary_properties_->GetVersion(); - } + [[nodiscard]] uint64_t GetVersion() const { return dictionary_properties_->GetVersion(); } private: dictionary_properties_t dictionary_properties_; @@ -478,9 +472,7 @@ class Automata final { friend class keyvi::dictionary::SecondaryKeyDictionary; - const dictionary_properties_t& GetDictionaryProperties() const { - return dictionary_properties_; - } + [[nodiscard]] const dictionary_properties_t& GetDictionaryProperties() const { return dictionary_properties_; } }; // shared pointer diff --git a/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_persistence.h b/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_persistence.h index 4a4a6b947..3365121ca 100644 --- a/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_persistence.h +++ b/keyvi/include/keyvi/dictionary/fsa/internal/sparse_array_persistence.h @@ -200,9 +200,7 @@ class SparseArrayPersistence final { TRACE("Wrote Transitions, stream at %d", stream.tellp()); } - size_t GetChunkSizeExternalTransitions() const { - return transitions_extern_->GetChunkSize(); - } + [[nodiscard]] size_t GetChunkSizeExternalTransitions() const { return transitions_extern_->GetChunkSize(); } uint32_t GetVersion() const;