From 25bd94ab85d19e52a7edbd6793411e1bc7181eb9 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 11:58:02 +0200 Subject: [PATCH 01/17] exclude benchmark from all, add to clang-tidy workflow Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 1 + tests/benchmark_cpp/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 5612b4cd5..7304c3ddb 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -24,6 +24,7 @@ on: - all - power_grid_model_c - power_grid_model_cpp + - install power_grid_model_benchmark_cpp required: true concurrency: diff --git a/tests/benchmark_cpp/CMakeLists.txt b/tests/benchmark_cpp/CMakeLists.txt index 22ee5c544..b42cc1cda 100644 --- a/tests/benchmark_cpp/CMakeLists.txt +++ b/tests/benchmark_cpp/CMakeLists.txt @@ -6,7 +6,7 @@ set(PROJECT_SOURCES benchmark.cpp ) -add_executable(power_grid_model_benchmark_cpp ${PROJECT_SOURCES}) +add_executable(power_grid_model_benchmark_cpp EXCLUDE_FROM_ALL ${PROJECT_SOURCES}) target_link_libraries(power_grid_model_benchmark_cpp PRIVATE power_grid_model ) From 3f806ec38000bf5ba0e9afc129bea0ec7dbd6ccb Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:13:54 +0200 Subject: [PATCH 02/17] add nightly Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 9 ++++++++- .github/workflows/main.yml | 2 ++ .github/workflows/nightly.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 7304c3ddb..373bd6992 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -13,6 +13,13 @@ on: pull_request: # run pipeline on merge queue merge_group: + # run pipeline from another workflow + workflow_call: + inputs: + target: + type: string + description: "The CMake target to run (e.g.: all)" + required: true # run this workflow manually from the Actions tab workflow_dispatch: inputs: @@ -24,7 +31,7 @@ on: - all - power_grid_model_c - power_grid_model_cpp - - install power_grid_model_benchmark_cpp + - all power_grid_model_benchmark_cpp required: true concurrency: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9d10b81b1..d9cde12fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,8 @@ on: pull_request: # run pipeline on merge queue merge_group: + # run pipeline from another workflow + workflow_call: # run this workflow manually from the Actions tab workflow_dispatch: inputs: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..e35219427 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: Contributors to the Power Grid Model project +# +# SPDX-License-Identifier: MPL-2.0 + +name: Nightly build + +# Controls when the workflow will run +on: + pull_request: + # run pipeline on merge queue + paths: + - "./.github/workflows/nightly.yml" + workflow_dispatch: + schedule: + - cron: "0 2 * * *" # Based on UTC time + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + main: + uses: "./.github/workflows/main.yml" + + clang-tidy: + uses: "./.github/workflows/clang-tidy.yml" + with: + target: "all power_grid_model_benchmark_cpp" From 74a60f42c558b87ea0339276f360cb12e0320086 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:21:12 +0200 Subject: [PATCH 03/17] re-attempt enable nightly Signed-off-by: Martijn Govers --- .github/workflows/nightly.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e35219427..0bad4fec6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,10 +6,10 @@ name: Nightly build # Controls when the workflow will run on: - pull_request: - # run pipeline on merge queue - paths: - - "./.github/workflows/nightly.yml" + pull_request: # TODO: re-enable + # # run pipeline on merge queue + # paths: + # - "./.github/workflows/nightly.yml" workflow_dispatch: schedule: - cron: "0 2 * * *" # Based on UTC time @@ -19,8 +19,8 @@ concurrency: cancel-in-progress: true jobs: - main: - uses: "./.github/workflows/main.yml" +# main: +# uses: "./.github/workflows/main.yml" clang-tidy: uses: "./.github/workflows/clang-tidy.yml" From d019115049077fc713d40f63f9fa63afa4f93369 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:22:50 +0200 Subject: [PATCH 04/17] attempt resolve deadlock Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 373bd6992..889fa0469 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -11,6 +11,8 @@ on: - main # run pipeline on pull request pull_request: + paths-ignore: + - "./.github/workflows/nightly.yml" # run pipeline on merge queue merge_group: # run pipeline from another workflow From 6a8f3f7d6a0fe71ef51751ba14bc63a30532126d Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:24:20 +0200 Subject: [PATCH 05/17] remove deadlock Signed-off-by: Martijn Govers --- .github/workflows/nightly.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 0bad4fec6..2c5a3eb17 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,10 +6,10 @@ name: Nightly build # Controls when the workflow will run on: - pull_request: # TODO: re-enable - # # run pipeline on merge queue - # paths: - # - "./.github/workflows/nightly.yml" + pull_request: + # run pipeline on merge queue + paths: + - "./.github/workflows/nightly.yml" workflow_dispatch: schedule: - cron: "0 2 * * *" # Based on UTC time From e86362769f91b3b3809ba7335b64614f637cd490 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:25:50 +0200 Subject: [PATCH 06/17] just skip deadlock altogether Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 4 +--- .github/workflows/nightly.yml | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 889fa0469..77c230b3f 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -10,9 +10,7 @@ on: branches: - main # run pipeline on pull request - pull_request: - paths-ignore: - - "./.github/workflows/nightly.yml" + # pull_request: # TODO: reenable # run pipeline on merge queue merge_group: # run pipeline from another workflow diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2c5a3eb17..cce2027e2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,10 +6,7 @@ name: Nightly build # Controls when the workflow will run on: - pull_request: - # run pipeline on merge queue - paths: - - "./.github/workflows/nightly.yml" + pull_request: # TODO: remove workflow_dispatch: schedule: - cron: "0 2 * * *" # Based on UTC time From 1f35c8799fe203aa8ab2c8a88f6daf7f026223ab Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:31:02 +0200 Subject: [PATCH 07/17] resolve some TODOs Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 2 +- .github/workflows/nightly.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 77c230b3f..373bd6992 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -10,7 +10,7 @@ on: branches: - main # run pipeline on pull request - # pull_request: # TODO: reenable + pull_request: # run pipeline on merge queue merge_group: # run pipeline from another workflow diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index cce2027e2..c25f8045f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,20 +6,20 @@ name: Nightly build # Controls when the workflow will run on: - pull_request: # TODO: remove workflow_dispatch: schedule: - cron: "0 2 * * *" # Based on UTC time - + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: -# main: -# uses: "./.github/workflows/main.yml" + main: + uses: "./.github/workflows/main.yml" clang-tidy: uses: "./.github/workflows/clang-tidy.yml" with: - target: "all power_grid_model_benchmark_cpp" + target: "power_grid_model_cpp" + # target: "all power_grid_model_benchmark_cpp" # TODO(mgovers): re-enable when more clang-tidy stuff is fixed From f4f61eae60ead4a847f55d1d1f11a2202a6b63a8 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:33:52 +0200 Subject: [PATCH 08/17] fix target option Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 4 ++-- .github/workflows/nightly.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 373bd6992..41e51f761 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -26,11 +26,11 @@ on: target: type: choice description: The CMake target to run - default: power_grid_model_c + default: power_grid_model_api_tests options: - all - power_grid_model_c - - power_grid_model_cpp + - power_grid_model_api_tests - all power_grid_model_benchmark_cpp required: true diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c25f8045f..688df5526 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -21,5 +21,5 @@ jobs: clang-tidy: uses: "./.github/workflows/clang-tidy.yml" with: - target: "power_grid_model_cpp" + target: power_grid_model_c # target: "all power_grid_model_benchmark_cpp" # TODO(mgovers): re-enable when more clang-tidy stuff is fixed From 0147ec3574d81192c2e42830babe86925849e1c7 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:36:54 +0200 Subject: [PATCH 09/17] fix Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 41e51f761..6aa0df237 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -26,7 +26,7 @@ on: target: type: choice description: The CMake target to run - default: power_grid_model_api_tests + default: power_grid_model_c options: - all - power_grid_model_c @@ -70,12 +70,12 @@ jobs: brew install boost eigen nlohmann-json msgpack-cxx doctest - name: Set build target in case of push - if: github.event_name != 'workflow_dispatch' + if: github.event_name != 'workflow_dispatch' || github.event.event_name != 'workflow_call' run: | - echo "TARGET=power_grid_model_c" >> $GITHUB_ENV + echo "TARGET=power_grid_model_api_tests" >> $GITHUB_ENV - name: Set build target in case of workflow dispatch - if: github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' || github.event.event_name == 'workflow_call' run: | echo "TARGET=${{ github.event.inputs.target }}" >> $GITHUB_ENV From dccaae859b31f5f1557d78a54953788b7468d63f Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 12:37:14 +0200 Subject: [PATCH 10/17] fix Signed-off-by: Martijn Govers --- .github/workflows/clang-tidy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 6aa0df237..6c8ce5e2d 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -70,7 +70,7 @@ jobs: brew install boost eigen nlohmann-json msgpack-cxx doctest - name: Set build target in case of push - if: github.event_name != 'workflow_dispatch' || github.event.event_name != 'workflow_call' + if: github.event_name != 'workflow_dispatch' && github.event.event_name != 'workflow_call' run: | echo "TARGET=power_grid_model_api_tests" >> $GITHUB_ENV From 6381fe83e9fce8b53781a3dfec9ba27acc3d7b47 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 13:25:07 +0200 Subject: [PATCH 11/17] clang-tidy Signed-off-by: Martijn Govers --- .../auxiliary/serialization/deserializer.hpp | 2 +- .../auxiliary/serialization/serializer.hpp | 2 +- .../power_grid_model/common/exception.hpp | 4 +- .../common/three_phase_tensor.hpp | 8 ++-- .../include/power_grid_model_cpp/buffer.hpp | 4 +- .../include/power_grid_model_cpp/dataset.hpp | 40 +++++++++---------- tests/native_api_tests/test_api_model.cpp | 2 +- .../test_api_serialization.cpp | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp index 861d69cb2..00d02a04b 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp @@ -385,7 +385,7 @@ class Deserializer { Deserializer& operator=(Deserializer const&) = delete; // movable Deserializer(Deserializer&&) = default; - Deserializer& operator=(Deserializer&&) = default; + Deserializer& operator=(Deserializer&&) noexcept = default; // destructor ~Deserializer() = default; diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp index 81b00977c..35f1b3717 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp @@ -23,7 +23,7 @@ #include // custom packers -namespace msgpack { +namespace msgpack { // NOLINT(modernize-concat-nested-namespaces) MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) { namespace adaptor { diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp index 5bcb632dc..1771f1571 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp @@ -44,7 +44,9 @@ class InvalidArguments : public PowerGridError { template requires(std::same_as, TypeValuePair> && ...) - InvalidArguments(std::string const& method, Options&&... options) + InvalidArguments( + std::string const& method, + Options&&... options) // NOLINT(cppcoreguidelines-missing-std-forward) // false positive by clang-tidy : InvalidArguments{method, "the following combination of options"} { (append_msg(" " + std::forward(options).name + ": " + std::forward(options).value + "\n"), ...); diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp index 6b2144b2b..1a726c8ba 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp @@ -338,15 +338,17 @@ inline auto all_zero(RealValue const& value) { return (value == Re // // The function assumes that the current value is normalized and new value should be normalized with scalar template -inline void update_real_value(RealValue const& new_value, Proxy&& current_value, double scalar) { +inline void +update_real_value(RealValue const& new_value, Proxy&& current_value, + double scalar) { // NOLINT(cppcoreguidelines-missing-std-forward) // false positive by clang-tidy if constexpr (is_symmetric_v) { if (!is_nan(new_value)) { - current_value = scalar * new_value; + std::forward(current_value) = scalar * new_value; } } else { for (size_t i = 0; i != 3; ++i) { if (!is_nan(new_value(i))) { - current_value(i) = scalar * new_value(i); + std::forward(current_value)(i) = scalar * new_value(i); } } } diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp index 9f96024ef..b78a4063d 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp @@ -28,8 +28,8 @@ class Buffer { void set_nan(Idx buffer_offset) { set_nan(*this, buffer_offset, 1); } void set_nan(Idx buffer_offset, Idx size) { set_nan(*this, buffer_offset, size); } - static void set_value(MetaAttribute const* attribute, Buffer const& buffer, RawDataConstPtr src_ptr, - Idx buffer_offset, Idx size, Idx src_stride) { + static void set_value(MetaAttribute const* attribute, Buffer& buffer, RawDataConstPtr src_ptr, Idx buffer_offset, + Idx size, Idx src_stride) { buffer.handle_.call_with(PGM_buffer_set_value, attribute, buffer.buffer_.get(), src_ptr, buffer_offset, size, src_stride); } diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp index 4f4112851..9a2819916 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp @@ -127,43 +127,41 @@ class DatasetMutable { RawMutableDataset* get() const { return dataset_.get(); } - static void add_buffer(DatasetMutable const& dataset, std::string const& component, Idx elements_per_scenario, + static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - RawDataPtr data) { // NOSONAR: no const + RawDataPtr data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_buffer(DatasetMutable const& dataset, std::string const& component, Idx elements_per_scenario, + static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - Buffer const& data) { // NOSONAR: no const + Buffer const& data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_attribute_buffer(DatasetMutable const& dataset, std::string const& component, + static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, std::string const& attribute, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - RawDataPtr data) { // NOSONAR: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, RawDataPtr data) { add_attribute_buffer(*this, component, attribute, data); } - static void add_attribute_buffer(DatasetMutable const& dataset, std::string const& component, + static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, std::string const& attribute, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - Buffer const& data) { // NOSONAR: no const: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, Buffer const& data) { add_attribute_buffer(*this, component, attribute, data); } @@ -190,43 +188,41 @@ class DatasetConst { RawConstDataset* get() const { return dataset_.get(); } - static void add_buffer(DatasetConst const& dataset, std::string const& component, Idx elements_per_scenario, + static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, RawDataConstPtr data) { dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - RawDataConstPtr data) { // NOSONAR: no const + RawDataConstPtr data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_buffer(DatasetConst const& dataset, std::string const& component, Idx elements_per_scenario, + static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - Buffer const& data) { // NOSONAR: no const + Buffer const& data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_attribute_buffer(DatasetConst const& dataset, std::string const& component, - std::string const& attribute, RawDataConstPtr data) { + static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, + RawDataConstPtr data) { dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - RawDataConstPtr data) { // NOSONAR: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, RawDataConstPtr data) { add_attribute_buffer(*this, component, attribute, data); } - static void add_attribute_buffer(DatasetConst const& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { + static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, + Buffer const& data) { dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - Buffer const& data) { // NOSONAR: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, Buffer const& data) { add_attribute_buffer(*this, component, attribute, data); } diff --git a/tests/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 8deba7a59..9d2249d42 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -222,7 +222,7 @@ TEST_CASE("API Model") { } SUBCASE("Copy model") { - Model model_copy{model}; + auto const model_copy = Model{model}; model_copy.calculate(options, single_output_dataset); node_output.get_value(PGM_def_sym_output_node_id, node_result_id.data(), -1); node_output.get_value(PGM_def_sym_output_node_energized, node_result_energized.data(), 0, -1); diff --git a/tests/native_api_tests/test_api_serialization.cpp b/tests/native_api_tests/test_api_serialization.cpp index 7eb77e3cd..fe1b6a8a2 100644 --- a/tests/native_api_tests/test_api_serialization.cpp +++ b/tests/native_api_tests/test_api_serialization.cpp @@ -192,7 +192,7 @@ TEST_CASE("API Serialization and Deserialization") { ID node_id_2{0}; double node_u_rated_2; // set buffer - Buffer source_buffer_columnar{PGM_def_input_source, 1}; + Buffer const source_buffer_columnar{PGM_def_input_source, 1}; dataset.set_buffer("node", nullptr, nullptr); dataset.set_attribute_buffer("node", "id", &node_id_2); dataset.set_attribute_buffer("node", "u_rated", &node_u_rated_2); From 5eaaef20bae87efe9285ce155aba31ab90e9d334 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 13:48:17 +0200 Subject: [PATCH 12/17] revert core clang-tidy stuff that fails on windows Signed-off-by: Martijn Govers --- .../include/power_grid_model/common/exception.hpp | 4 +--- .../power_grid_model/common/three_phase_tensor.hpp | 8 +++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp index 1771f1571..5bcb632dc 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp @@ -44,9 +44,7 @@ class InvalidArguments : public PowerGridError { template requires(std::same_as, TypeValuePair> && ...) - InvalidArguments( - std::string const& method, - Options&&... options) // NOLINT(cppcoreguidelines-missing-std-forward) // false positive by clang-tidy + InvalidArguments(std::string const& method, Options&&... options) : InvalidArguments{method, "the following combination of options"} { (append_msg(" " + std::forward(options).name + ": " + std::forward(options).value + "\n"), ...); diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp index 1a726c8ba..6b2144b2b 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp @@ -338,17 +338,15 @@ inline auto all_zero(RealValue const& value) { return (value == Re // // The function assumes that the current value is normalized and new value should be normalized with scalar template -inline void -update_real_value(RealValue const& new_value, Proxy&& current_value, - double scalar) { // NOLINT(cppcoreguidelines-missing-std-forward) // false positive by clang-tidy +inline void update_real_value(RealValue const& new_value, Proxy&& current_value, double scalar) { if constexpr (is_symmetric_v) { if (!is_nan(new_value)) { - std::forward(current_value) = scalar * new_value; + current_value = scalar * new_value; } } else { for (size_t i = 0; i != 3; ++i) { if (!is_nan(new_value(i))) { - std::forward(current_value)(i) = scalar * new_value(i); + current_value(i) = scalar * new_value(i); } } } From 8041f3c77f70a6cbf6f78a72a50cffb61e705aeb Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 14:56:29 +0200 Subject: [PATCH 13/17] re-disable sonar Signed-off-by: Martijn Govers --- .../include/power_grid_model_cpp/buffer.hpp | 2 +- .../include/power_grid_model_cpp/dataset.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp index b78a4063d..8869580ad 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp @@ -29,7 +29,7 @@ class Buffer { void set_nan(Idx buffer_offset, Idx size) { set_nan(*this, buffer_offset, size); } static void set_value(MetaAttribute const* attribute, Buffer& buffer, RawDataConstPtr src_ptr, Idx buffer_offset, - Idx size, Idx src_stride) { + Idx size, Idx src_stride) { // NOSONAR(cpp:S995) buffer.handle_.call_with(PGM_buffer_set_value, attribute, buffer.buffer_.get(), src_ptr, buffer_offset, size, src_stride); } diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp index 9a2819916..be8fa5db4 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp @@ -189,7 +189,7 @@ class DatasetConst { RawConstDataset* get() const { return dataset_.get(); } static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataConstPtr data) { + Idx total_elements, Idx const* indptr, RawDataConstPtr data) { // NOSONAR(cpp:S995) dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } @@ -199,7 +199,7 @@ class DatasetConst { } static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, Buffer const& data) { + Idx total_elements, Idx const* indptr, Buffer const& data) { // NOSONAR(cpp:S995) dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } @@ -209,7 +209,7 @@ class DatasetConst { } static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - RawDataConstPtr data) { + RawDataConstPtr data) { // NOSONAR(cpp:S995) dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } @@ -218,7 +218,7 @@ class DatasetConst { } static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - Buffer const& data) { + Buffer const& data) { // NOSONAR(cpp:S995) dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } From d7803bae68840d04169d21b85929a84ade889d3a Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 15:13:33 +0200 Subject: [PATCH 14/17] minor Signed-off-by: Martijn Govers --- .../include/power_grid_model_cpp/buffer.hpp | 2 +- .../include/power_grid_model_cpp/dataset.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp index 8869580ad..24f8aed37 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp @@ -29,7 +29,7 @@ class Buffer { void set_nan(Idx buffer_offset, Idx size) { set_nan(*this, buffer_offset, size); } static void set_value(MetaAttribute const* attribute, Buffer& buffer, RawDataConstPtr src_ptr, Idx buffer_offset, - Idx size, Idx src_stride) { // NOSONAR(cpp:S995) + Idx size, Idx src_stride) { // NOSONAR: no const buffer.handle_.call_with(PGM_buffer_set_value, attribute, buffer.buffer_.get(), src_ptr, buffer_offset, size, src_stride); } diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp index be8fa5db4..bb7e57e9d 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp @@ -189,7 +189,7 @@ class DatasetConst { RawConstDataset* get() const { return dataset_.get(); } static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataConstPtr data) { // NOSONAR(cpp:S995) + Idx total_elements, Idx const* indptr, RawDataConstPtr data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } @@ -199,7 +199,7 @@ class DatasetConst { } static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, Buffer const& data) { // NOSONAR(cpp:S995) + Idx total_elements, Idx const* indptr, Buffer const& data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } @@ -209,7 +209,7 @@ class DatasetConst { } static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - RawDataConstPtr data) { // NOSONAR(cpp:S995) + RawDataConstPtr data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } @@ -218,7 +218,7 @@ class DatasetConst { } static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - Buffer const& data) { // NOSONAR(cpp:S995) + Buffer const& data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } From faadbd934f8a86b43463d24c2f5fb88830e406f4 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 25 Sep 2024 16:54:56 +0200 Subject: [PATCH 15/17] minor Signed-off-by: Martijn Govers --- .../include/power_grid_model_cpp/dataset.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp index bb7e57e9d..5ddada134 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp @@ -80,14 +80,16 @@ class DatasetWritable { static DatasetInfo const& get_info(DatasetWritable const& dataset) { return dataset.info_; } DatasetInfo const& get_info() const { return get_info(*this); } - static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, RawDataPtr data) { + static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, + RawDataPtr data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data); } void set_buffer(std::string const& component, Idx* indptr, RawDataPtr data) { set_buffer(*this, component, indptr, data); } - static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, Buffer const& data) { + static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, + Buffer const& data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data.get()); } @@ -96,7 +98,7 @@ class DatasetWritable { } static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { + std::string const& attribute, RawDataPtr data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data); } @@ -105,7 +107,7 @@ class DatasetWritable { } static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { + std::string const& attribute, Buffer const& data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data.get()); } @@ -128,7 +130,7 @@ class DatasetMutable { RawMutableDataset* get() const { return dataset_.get(); } static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataPtr data) { + Idx total_elements, Idx const* indptr, RawDataPtr data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } @@ -138,7 +140,7 @@ class DatasetMutable { } static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, Buffer const& data) { + Idx total_elements, Idx const* indptr, Buffer const& data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } @@ -148,7 +150,7 @@ class DatasetMutable { } static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { + std::string const& attribute, RawDataPtr data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } @@ -157,7 +159,7 @@ class DatasetMutable { } static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { + std::string const& attribute, Buffer const& data) { // NOSONAR: no const dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } From 1890520f7d1e39dea19e98f59c34e03abeac27d6 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Thu, 26 Sep 2024 09:13:35 +0200 Subject: [PATCH 16/17] no reference-to-const Signed-off-by: Martijn Govers --- .../include/power_grid_model_cpp/buffer.hpp | 2 +- .../include/power_grid_model_cpp/dataset.hpp | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp index 24f8aed37..97c49aba6 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp @@ -29,7 +29,7 @@ class Buffer { void set_nan(Idx buffer_offset, Idx size) { set_nan(*this, buffer_offset, size); } static void set_value(MetaAttribute const* attribute, Buffer& buffer, RawDataConstPtr src_ptr, Idx buffer_offset, - Idx size, Idx src_stride) { // NOSONAR: no const + Idx size, Idx src_stride) { // NOSONAR: no reference-to-const buffer.handle_.call_with(PGM_buffer_set_value, attribute, buffer.buffer_.get(), src_ptr, buffer_offset, size, src_stride); } diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp index 5ddada134..2074cd50f 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp @@ -81,7 +81,7 @@ class DatasetWritable { DatasetInfo const& get_info() const { return get_info(*this); } static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, - RawDataPtr data) { // NOSONAR: no const + RawDataPtr data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data); } void set_buffer(std::string const& component, Idx* indptr, RawDataPtr data) { @@ -89,7 +89,7 @@ class DatasetWritable { } static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, - Buffer const& data) { // NOSONAR: no const + Buffer const& data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data.get()); } @@ -98,7 +98,7 @@ class DatasetWritable { } static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { // NOSONAR: no const + std::string const& attribute, RawDataPtr data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data); } @@ -107,7 +107,8 @@ class DatasetWritable { } static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { // NOSONAR: no const + std::string const& attribute, + Buffer const& data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data.get()); } @@ -130,7 +131,7 @@ class DatasetMutable { RawMutableDataset* get() const { return dataset_.get(); } static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataPtr data) { // NOSONAR: no const + Idx total_elements, Idx const* indptr, RawDataPtr data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } @@ -140,7 +141,8 @@ class DatasetMutable { } static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, Buffer const& data) { // NOSONAR: no const + Idx total_elements, Idx const* indptr, + Buffer const& data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } @@ -150,7 +152,7 @@ class DatasetMutable { } static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { // NOSONAR: no const + std::string const& attribute, RawDataPtr data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } @@ -159,7 +161,8 @@ class DatasetMutable { } static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { // NOSONAR: no const + std::string const& attribute, + Buffer const& data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } @@ -191,7 +194,8 @@ class DatasetConst { RawConstDataset* get() const { return dataset_.get(); } static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataConstPtr data) { // NOSONAR: no const + Idx total_elements, Idx const* indptr, + RawDataConstPtr data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } @@ -201,7 +205,8 @@ class DatasetConst { } static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, Buffer const& data) { // NOSONAR: no const + Idx total_elements, Idx const* indptr, + Buffer const& data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } @@ -211,7 +216,7 @@ class DatasetConst { } static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - RawDataConstPtr data) { // NOSONAR: no const + RawDataConstPtr data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } @@ -220,7 +225,7 @@ class DatasetConst { } static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - Buffer const& data) { // NOSONAR: no const + Buffer const& data) { // NOSONAR: no reference-to-const dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } From 8144221b43796760db04eb37cd3c6d5cfb060233 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Thu, 26 Sep 2024 09:36:35 +0200 Subject: [PATCH 17/17] more attempt to shut up sonar cloud where it actually needs to Signed-off-by: Martijn Govers --- .../include/power_grid_model_cpp/buffer.hpp | 4 +- .../include/power_grid_model_cpp/dataset.hpp | 57 +++++++++---------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp index 97c49aba6..c4f9cd7ca 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp @@ -28,8 +28,8 @@ class Buffer { void set_nan(Idx buffer_offset) { set_nan(*this, buffer_offset, 1); } void set_nan(Idx buffer_offset, Idx size) { set_nan(*this, buffer_offset, size); } - static void set_value(MetaAttribute const* attribute, Buffer& buffer, RawDataConstPtr src_ptr, Idx buffer_offset, - Idx size, Idx src_stride) { // NOSONAR: no reference-to-const + static void set_value(MetaAttribute const* attribute, Buffer& buffer, // NOSONAR: no reference-to-const + RawDataConstPtr src_ptr, Idx buffer_offset, Idx size, Idx src_stride) { buffer.handle_.call_with(PGM_buffer_set_value, attribute, buffer.buffer_.get(), src_ptr, buffer_offset, size, src_stride); } diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp index 2074cd50f..039860304 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp @@ -80,16 +80,16 @@ class DatasetWritable { static DatasetInfo const& get_info(DatasetWritable const& dataset) { return dataset.info_; } DatasetInfo const& get_info() const { return get_info(*this); } - static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, - RawDataPtr data) { // NOSONAR: no reference-to-const + static void set_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx* indptr, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data); } void set_buffer(std::string const& component, Idx* indptr, RawDataPtr data) { set_buffer(*this, component, indptr, data); } - static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, - Buffer const& data) { // NOSONAR: no reference-to-const + static void set_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data.get()); } @@ -97,8 +97,8 @@ class DatasetWritable { set_buffer(*this, component, indptr, data); } - static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { // NOSONAR: no reference-to-const + static void set_attribute_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data); } @@ -106,9 +106,8 @@ class DatasetWritable { set_attribute_buffer(*this, component, attribute, data); } - static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, - Buffer const& data) { // NOSONAR: no reference-to-const + static void set_attribute_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data.get()); } @@ -130,8 +129,9 @@ class DatasetMutable { RawMutableDataset* get() const { return dataset_.get(); } - static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataPtr data) { // NOSONAR: no reference-to-const + static void add_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } @@ -140,9 +140,9 @@ class DatasetMutable { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_buffer(DatasetMutable& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, - Buffer const& data) { // NOSONAR: no reference-to-const + static void add_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } @@ -151,8 +151,8 @@ class DatasetMutable { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { // NOSONAR: no reference-to-const + static void add_attribute_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } @@ -160,9 +160,8 @@ class DatasetMutable { add_attribute_buffer(*this, component, attribute, data); } - static void add_attribute_buffer(DatasetMutable& dataset, std::string const& component, - std::string const& attribute, - Buffer const& data) { // NOSONAR: no reference-to-const + static void add_attribute_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } @@ -193,9 +192,9 @@ class DatasetConst { RawConstDataset* get() const { return dataset_.get(); } - static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, - RawDataConstPtr data) { // NOSONAR: no reference-to-const + static void add_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, RawDataConstPtr data) { dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } @@ -204,9 +203,9 @@ class DatasetConst { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_buffer(DatasetConst& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, - Buffer const& data) { // NOSONAR: no reference-to-const + static void add_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } @@ -215,8 +214,8 @@ class DatasetConst { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - RawDataConstPtr data) { // NOSONAR: no reference-to-const + static void add_attribute_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, RawDataConstPtr data) { dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } @@ -224,8 +223,8 @@ class DatasetConst { add_attribute_buffer(*this, component, attribute, data); } - static void add_attribute_buffer(DatasetConst& dataset, std::string const& component, std::string const& attribute, - Buffer const& data) { // NOSONAR: no reference-to-const + static void add_attribute_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); }