Skip to content

Commit 4b5f081

Browse files
authored
[CodeHealth] Fix clang-tidy warnings part 3 (#3498)
1 parent f74d413 commit 4b5f081

22 files changed

+93
-40
lines changed

.github/workflows/clang-tidy.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
matrix:
1818
include:
1919
- cmake_options: all-options-abiv1-preview
20-
warning_limit: 109
20+
warning_limit: 86
2121
- cmake_options: all-options-abiv2-preview
22-
warning_limit: 109
22+
warning_limit: 86
2323
steps:
2424
- name: Harden the runner (Audit all outbound calls)
2525
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Increment the:
3636
* [CodeHealth] Fix clang-tidy warnings part 2
3737
[#3496](https://github.com/open-telemetry/opentelemetry-cpp/pull/3496)
3838

39+
* [CodeHealth] Fix clang-tidy warnings part 3
40+
[#3496](https://github.com/open-telemetry/opentelemetry-cpp/pull/3498)
41+
3942
Important changes:
4043

4144
* [REMOVAL] Removed deprecated semantic convention header files

api/test/context/propagation/composite_propagator_test.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ class CompositePropagatorTest : public ::testing::Test
7373
propogator_list.push_back(std::move(b3_propogator));
7474

7575
composite_propagator_ =
76-
new context::propagation::CompositePropagator(std::move(propogator_list));
76+
std::make_shared<context::propagation::CompositePropagator>(std::move(propogator_list));
7777
}
7878

79-
~CompositePropagatorTest() override { delete composite_propagator_; }
80-
8179
protected:
82-
context::propagation::CompositePropagator *composite_propagator_;
80+
std::shared_ptr<context::propagation::CompositePropagator> composite_propagator_;
8381
};
8482

8583
TEST_F(CompositePropagatorTest, Extract)

api/test/nostd/shared_ptr_test.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class A
1919

2020
~A() { destructed_ = true; }
2121

22+
A(const A &) = delete;
23+
A(A &&) = delete;
24+
A &operator=(const A &) = delete;
25+
A &operator=(A &&) = delete;
26+
2227
private:
2328
bool &destructed_;
2429
};
@@ -33,13 +38,16 @@ class C
3338
{
3439
public:
3540
virtual ~C() {}
41+
C() = default;
42+
43+
C(const C &) = delete;
44+
C(C &&) = delete;
45+
C &operator=(const C &) = delete;
46+
C &operator=(C &&) = delete;
3647
};
3748

3849
class D : public C
39-
{
40-
public:
41-
~D() override {}
42-
};
50+
{};
4351

4452
TEST(SharedPtrTest, DefaultConstruction)
4553
{

api/test/nostd/unique_ptr_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class A
1717

1818
~A() { destructed_ = true; }
1919

20+
A(const A &) = delete;
21+
A(A &&) = delete;
22+
A &operator=(const A &) = delete;
23+
A &operator=(A &&) = delete;
24+
2025
private:
2126
bool &destructed_;
2227
};

api/test/nostd/variant_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class DestroyCounter
1414
explicit DestroyCounter(int *count) : count_{count} {}
1515
~DestroyCounter() { ++*count_; }
1616

17+
DestroyCounter(const DestroyCounter &) = default;
18+
DestroyCounter &operator=(const DestroyCounter &) = default;
19+
DestroyCounter(DestroyCounter &&) = default;
20+
DestroyCounter &operator=(DestroyCounter &&) = default;
21+
1722
private:
1823
int *count_;
1924
};

examples/otlp/http_instrumented_main.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class MyThreadInstrumentation : public opentelemetry::sdk::common::ThreadInstrum
8989
const std::string &priority)
9090
: thread_name_(thread_name), network_name_(network_name), priority_(priority)
9191
{}
92-
~MyThreadInstrumentation() override = default;
9392

9493
void OnStart() override
9594
{

examples/plugin/plugin/tracer.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class Span final : public trace::Span
3535

3636
~Span() override { std::cout << "~Span\n"; }
3737

38+
Span(const Span &) = delete;
39+
Span &operator=(const Span &) = delete;
40+
Span(Span &&) = delete;
41+
Span &operator=(Span &&) = delete;
42+
3843
// opentelemetry::trace::Span
3944
void SetAttribute(nostd::string_view /*name*/,
4045
const common::AttributeValue & /*value*/) noexcept override

exporters/elasticsearch/src/es_log_record_exporter.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ class AsyncResponseHandler : public http_client::EventHandler
223223
console_debug_{console_debug}
224224
{}
225225

226+
AsyncResponseHandler(const AsyncResponseHandler &) = delete;
227+
AsyncResponseHandler &operator=(const AsyncResponseHandler &) = delete;
228+
AsyncResponseHandler(AsyncResponseHandler &&) = delete;
229+
AsyncResponseHandler &operator=(AsyncResponseHandler &&) = delete;
230+
226231
/**
227232
* Cleans up the session in the destructor.
228233
*/

exporters/otlp/src/otlp_grpc_client.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpGrpcAsyncCallDataBase
6767
opentelemetry::sdk::common::ExportResult::kFailure;
6868
GrpcAsyncCallback grpc_async_callback = nullptr;
6969

70-
OtlpGrpcAsyncCallDataBase() {}
71-
virtual ~OtlpGrpcAsyncCallDataBase() {}
70+
OtlpGrpcAsyncCallDataBase() = default;
71+
virtual ~OtlpGrpcAsyncCallDataBase() = default;
72+
OtlpGrpcAsyncCallDataBase(const OtlpGrpcAsyncCallDataBase &) = delete;
73+
OtlpGrpcAsyncCallDataBase &operator=(const OtlpGrpcAsyncCallDataBase &) = delete;
74+
OtlpGrpcAsyncCallDataBase(OtlpGrpcAsyncCallDataBase &&) = delete;
75+
OtlpGrpcAsyncCallDataBase &operator=(OtlpGrpcAsyncCallDataBase &&) = delete;
7276
};
7377

7478
// When building with -fvisibility=default, we hide the symbols and vtable to ensure we always use
@@ -90,8 +94,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpGrpcAsyncCallData : public OtlpGrpcAsyncCal
9094
ResponseType *)>
9195
result_callback;
9296

93-
OtlpGrpcAsyncCallData() {}
94-
~OtlpGrpcAsyncCallData() override {}
97+
OtlpGrpcAsyncCallData() = default;
9598
};
9699
} // namespace
97100
#endif

0 commit comments

Comments
 (0)