Skip to content

Commit a71642f

Browse files
authored
[Code Health] Clang Tidy cleanup, Part 2 (#3038)
1 parent 242d52a commit a71642f

34 files changed

+127
-125
lines changed

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ Checks: >
3131
-misc-unused-alias-decls,
3232
-misc-use-anonymous-namespace,
3333
cppcoreguidelines-*,
34+
-cppcoreguidelines-owning-memory,
35+
-cppcoreguidelines-avoid-do-while,
3436
-cppcoreguidelines-avoid-c-arrays,
3537
-cppcoreguidelines-avoid-magic-numbers,
3638
-cppcoreguidelines-init-variables,
3739
-cppcoreguidelines-macro-usage,
3840
-cppcoreguidelines-non-private-member-variables-in-classes,
41+
-cppcoreguidelines-avoid-non-const-global-variables,
3942
-cppcoreguidelines-pro-*

.github/workflows/clang-tidy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Run clang-tidy
6969
run: |
7070
cd build
71-
make -j$(nproc) 2>&1 | tee -a clang-tidy.log || exit 1
71+
make 2>&1 | tee -a clang-tidy.log || exit 1
7272
7373
- uses: actions/upload-artifact@v4
7474
with:

api/test/baggage/propagation/baggage_propagator_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BaggageCarrierTest : public context::propagation::TextMapCarrier
1515
{
1616
public:
1717
BaggageCarrierTest() = default;
18-
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
18+
nostd::string_view Get(nostd::string_view key) const noexcept override
1919
{
2020
auto it = headers_.find(std::string(key));
2121
if (it != headers_.end())
@@ -24,7 +24,7 @@ class BaggageCarrierTest : public context::propagation::TextMapCarrier
2424
}
2525
return "";
2626
}
27-
virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override
27+
void Set(nostd::string_view key, nostd::string_view value) noexcept override
2828
{
2929
headers_[std::string(key)] = std::string(value);
3030
}

api/test/context/propagation/composite_propagator_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static std::string Hex(const T &id_item)
3131
class TextMapCarrierTest : public context::propagation::TextMapCarrier
3232
{
3333
public:
34-
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
34+
nostd::string_view Get(nostd::string_view key) const noexcept override
3535
{
3636
auto it = headers_.find(std::string(key));
3737
if (it != headers_.end())
@@ -40,7 +40,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier
4040
}
4141
return "";
4242
}
43-
virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override
43+
void Set(nostd::string_view key, nostd::string_view value) noexcept override
4444
{
4545
headers_[std::string(key)] = std::string(value);
4646
}
@@ -66,7 +66,7 @@ class CompositePropagatorTest : public ::testing::Test
6666
new context::propagation::CompositePropagator(std::move(propogator_list));
6767
}
6868

69-
~CompositePropagatorTest() { delete composite_propagator_; }
69+
~CompositePropagatorTest() override { delete composite_propagator_; }
7070

7171
protected:
7272
context::propagation::CompositePropagator *composite_propagator_;

api/test/logs/logger_benchmark.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ constexpr int64_t kMaxIterations = 1000000000;
3232
class Barrier
3333
{
3434
public:
35-
explicit Barrier(std::size_t iCount) : mThreshold(iCount), mCount(iCount), mGeneration(0) {}
35+
explicit Barrier(std::size_t iCount) : mThreshold(iCount), mCount(iCount) {}
3636

3737
void Wait()
3838
{
@@ -55,7 +55,7 @@ class Barrier
5555
std::condition_variable mCond;
5656
std::size_t mThreshold;
5757
std::size_t mCount;
58-
std::size_t mGeneration;
58+
std::size_t mGeneration{0};
5959
};
6060

6161
static void ThreadRoutine(Barrier &barrier,
@@ -84,14 +84,14 @@ static void ThreadRoutine(Barrier &barrier,
8484

8585
void MultiThreadRunner(benchmark::State &state, const std::function<void()> &func)
8686
{
87-
int num_threads = std::thread::hardware_concurrency();
87+
uint32_t num_threads = std::thread::hardware_concurrency();
8888

8989
Barrier barrier(num_threads);
9090

9191
std::vector<std::thread> threads;
9292

9393
threads.reserve(num_threads);
94-
for (int i = 0; i < num_threads; i++)
94+
for (uint32_t i = 0; i < num_threads; i++)
9595
{
9696
threads.emplace_back(ThreadRoutine, std::ref(barrier), std::ref(state), i, func);
9797
}

api/test/nostd/shared_ptr_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class C
3535
class D : public C
3636
{
3737
public:
38-
virtual ~D() {}
38+
~D() override {}
3939
};
4040

4141
TEST(SharedPtrTest, DefaultConstruction)

api/test/trace/propagation/b3_propagation_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace opentelemetry;
1515
class TextMapCarrierTest : public context::propagation::TextMapCarrier
1616
{
1717
public:
18-
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
18+
nostd::string_view Get(nostd::string_view key) const noexcept override
1919
{
2020
auto it = headers_.find(std::string(key));
2121
if (it != headers_.end())
@@ -24,7 +24,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier
2424
}
2525
return "";
2626
}
27-
virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override
27+
void Set(nostd::string_view key, nostd::string_view value) noexcept override
2828
{
2929
headers_[std::string(key)] = std::string(value);
3030
}

api/test/trace/propagation/http_text_format_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace opentelemetry;
1818
class TextMapCarrierTest : public context::propagation::TextMapCarrier
1919
{
2020
public:
21-
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
21+
nostd::string_view Get(nostd::string_view key) const noexcept override
2222
{
2323
auto it = headers_.find(std::string(key));
2424
if (it != headers_.end())
@@ -27,7 +27,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier
2727
}
2828
return "";
2929
}
30-
virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override
30+
void Set(nostd::string_view key, nostd::string_view value) noexcept override
3131
{
3232
headers_[std::string(key)] = std::string(value);
3333
}

api/test/trace/propagation/jaeger_propagation_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace opentelemetry;
1414
class TextMapCarrierTest : public context::propagation::TextMapCarrier
1515
{
1616
public:
17-
virtual nostd::string_view Get(nostd::string_view key) const noexcept override
17+
nostd::string_view Get(nostd::string_view key) const noexcept override
1818
{
1919
auto it = headers_.find(std::string(key));
2020
if (it != headers_.end())
@@ -23,7 +23,7 @@ class TextMapCarrierTest : public context::propagation::TextMapCarrier
2323
}
2424
return "";
2525
}
26-
virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override
26+
void Set(nostd::string_view key, nostd::string_view value) noexcept override
2727
{
2828
headers_[std::string(key)] = std::string(value);
2929
}

examples/http/server.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ constexpr const char *server_name = "localhost";
2121
class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback
2222
{
2323
public:
24-
virtual int onHttpRequest(HTTP_SERVER_NS::HttpRequest const &request,
25-
HTTP_SERVER_NS::HttpResponse &response) override
24+
int onHttpRequest(HTTP_SERVER_NS::HttpRequest const &request,
25+
HTTP_SERVER_NS::HttpResponse &response) override
2626
{
2727
StartSpanOptions options;
2828
options.kind = SpanKind::kServer; // server

0 commit comments

Comments
 (0)