Skip to content

Commit

Permalink
Silence false-positives from clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jul 24, 2024
1 parent 93c556d commit 86ebbee
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/unittests/associations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ TEST_CASE("Association constness", "[associations][static-checks]") {
}

TEST_CASE("Association basics", "[associations]") {
// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): There are quite a few
// false positives here from clang-tidy that we are confident are false
// positives, because we don't see issues in our builds with sanitizers
auto cluster = MutableExampleCluster();
auto hit = MutableExampleHit();

Expand Down Expand Up @@ -82,7 +85,9 @@ TEST_CASE("Association basics", "[associations]") {
SECTION("Implicit conversion") {
// Use an immediately invoked lambda to check that the implicit conversion
// is working as desired
[hit, cluster](TestA assoc) { // NOLINT(performance-unnecessary-value-param)
[hit, cluster](TestA assoc) { // NOLINT(performance-unnecessary-value-param):
// We want the value here to force teh
// conversion
REQUIRE(assoc.getWeight() == 3.14f);
REQUIRE(assoc.getFrom() == hit);
REQUIRE(assoc.getTo() == cluster);
Expand Down Expand Up @@ -140,8 +145,12 @@ TEST_CASE("Association basics", "[associations]") {
REQUIRE(assoc != newAssoc);
}
}
// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)

TEST_CASE("Associations templated accessors", "[associations]") {
// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): There are quite a few
// false positives here from clang-tidy that we are confident are false
// positives, because we don't see issues in our builds with sanitizers
ExampleHit hit;
ExampleCluster cluster;

Expand Down Expand Up @@ -172,6 +181,7 @@ TEST_CASE("Associations templated accessors", "[associations]") {
REQUIRE(w == 1.0);
}
}
// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)

TEST_CASE("AssociationCollection constness", "[associations][static-checks][const-correctness]") {
// Test type-aliases in AssociationCollection
Expand Down Expand Up @@ -252,6 +262,9 @@ TEST_CASE("AssociationCollection constness", "[associations][static-checks][cons
}

TEST_CASE("AssociationCollection subset collection", "[associations][subset-colls]") {
// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): There are quite a few
// false positives here from clang-tidy that we are confident are false
// positives, because we don't see issues in our builds with sanitizers
auto assocs = TestAColl();
auto assoc1 = assocs.create();
assoc1.setWeight(1.0f);
Expand Down Expand Up @@ -292,6 +305,7 @@ TEST_CASE("AssociationCollection subset collection", "[associations][subset-coll
REQUIRE_THROWS_AS(assocRefs.create(), std::logic_error);
}
}
// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)

auto createAssocCollections(const size_t nElements = 3u) {
auto colls = std::make_tuple(TestAColl(), ExampleHitCollection(), ExampleClusterCollection());
Expand Down

0 comments on commit 86ebbee

Please sign in to comment.