Skip to content

Add clang-tidy support#97

Merged
alan-george-lk merged 59 commits intomainfrom
feature/clang-tidy
Apr 22, 2026
Merged

Add clang-tidy support#97
alan-george-lk merged 59 commits intomainfrom
feature/clang-tidy

Conversation

@alan-george-lk
Copy link
Copy Markdown
Contributor

@alan-george-lk alan-george-lk commented Apr 15, 2026

This PR adds support for clang-tidy static analysis within the CI. The list of initial checks can be found in the .clang-tidy file at the root of the repository.

Fixes to .h/.cpp files flagged by the analysis were also done.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-tidy v20.1.2

Click here for the full clang-tidy patch
diff --git a/src/video_frame.cpp b/src/video_frame.cpp
index 870dfee..63a30b3 100644
--- a/src/video_frame.cpp
+++ b/src/video_frame.cpp
@@ -298 +298 @@ VideoFrame VideoFrame::create(int width, int height, VideoBufferType type) {
-  return VideoFrame(width, height, type, std::move(buffer));
+  return {width, height, type, std::move(buffer)};
@@ -306 +306 @@ std::vector<VideoPlaneInfo> VideoFrame::planeInfos() const {
-  uintptr_t base = reinterpret_cast<uintptr_t>(data_.data());
+  auto base = reinterpret_cast<uintptr_t>(data_.data());
@@ -318 +318 @@ VideoFrame VideoFrame::convert(VideoBufferType dst, bool flip_y) const {
-    return VideoFrame(width_, height_, type_, std::move(buf));
+    return {width_, height_, type_, std::move(buf)};
@@ -376 +376 @@ VideoFrame VideoFrame::fromOwnedInfo(const proto::OwnedVideoBuffer &owned) {
-  return VideoFrame(width, height, type, std::move(buffer));
+  return {width, height, type, std::move(buffer)};
diff --git a/src/trace/event_tracer.cpp b/src/trace/event_tracer.cpp
index 8809993..3340f00 100644
--- a/src/trace/event_tracer.cpp
+++ b/src/trace/event_tracer.cpp
@@ -40,2 +40,2 @@
-namespace livekit {
-namespace trace {
+
+namespace livekit::trace {
@@ -179,3 +179,3 @@ std::string FormatEventJson(const TraceEventData &event, uint64_t start_time) {
-  oss << "\"ph\":\"" << event.phase << "\",";
-  oss << "\"cat\":\"" << JsonEscape(event.category) << "\",";
-  oss << "\"name\":\"" << JsonEscape(event.name) << "\",";
+  oss << R"("ph":")" << event.phase << "\",";
+  oss << R"("cat":")" << JsonEscape(event.category) << "\",";
+  oss << R"("name":")" << JsonEscape(event.name) << "\",";
@@ -187 +187 @@ std::string FormatEventJson(const TraceEventData &event, uint64_t start_time) {
-    oss << ",\"id\":\"0x" << std::hex << event.id << std::dec << "\"";
+    oss << R"(,"id":"0x)" << std::hex << event.id << std::dec << "\"";
@@ -430 +430 @@ void StopTracing() {
-    g_trace_file << "],\"displayTimeUnit\":\"ms\"}";
+    g_trace_file << R"(],"displayTimeUnit":"ms"})";
@@ -444,2 +444,2 @@ bool IsTracingEnabled() {
-} // namespace trace
-} // namespace livekit
+} // namespace livekit::trace
+

Have any feedback or feature suggestions? Share it here.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-tidy v20.1.2

Click here for the full clang-tidy patch
diff --git a/src/trace/event_tracer.cpp b/src/trace/event_tracer.cpp
index 8809993..3340f00 100644
--- a/src/trace/event_tracer.cpp
+++ b/src/trace/event_tracer.cpp
@@ -40,2 +40,2 @@
-namespace livekit {
-namespace trace {
+
+namespace livekit::trace {
@@ -179,3 +179,3 @@ std::string FormatEventJson(const TraceEventData &event, uint64_t start_time) {
-  oss << "\"ph\":\"" << event.phase << "\",";
-  oss << "\"cat\":\"" << JsonEscape(event.category) << "\",";
-  oss << "\"name\":\"" << JsonEscape(event.name) << "\",";
+  oss << R"("ph":")" << event.phase << "\",";
+  oss << R"("cat":")" << JsonEscape(event.category) << "\",";
+  oss << R"("name":")" << JsonEscape(event.name) << "\",";
@@ -187 +187 @@ std::string FormatEventJson(const TraceEventData &event, uint64_t start_time) {
-    oss << ",\"id\":\"0x" << std::hex << event.id << std::dec << "\"";
+    oss << R"(,"id":"0x)" << std::hex << event.id << std::dec << "\"";
@@ -430 +430 @@ void StopTracing() {
-    g_trace_file << "],\"displayTimeUnit\":\"ms\"}";
+    g_trace_file << R"(],"displayTimeUnit":"ms"})";
@@ -444,2 +444,2 @@ bool IsTracingEnabled() {
-} // namespace trace
-} // namespace livekit
+} // namespace livekit::trace
+

Have any feedback or feature suggestions? Share it here.

@alan-george-lk alan-george-lk changed the title Draft v2 - Add clang-tidy support Add clang-tidy support Apr 17, 2026
Comment thread src/room_proto_converter.cpp
Comment thread include/livekit/audio_stream.h
Comment thread build.sh
Copy link
Copy Markdown
Contributor

@stephen-derosa stephen-derosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general this looks good, thanks for doing! I have some questions/comments, nothing major

Comment thread .github/workflows/builds.yml
Comment thread bridge/include/livekit_bridge/rpc_constants.h
Comment thread include/livekit/audio_stream.h
Comment thread include/livekit/data_stream.h
Comment thread include/livekit/subscription_thread_dispatcher.h
Comment thread src/subscription_thread_dispatcher.cpp
Comment thread src/subscription_thread_dispatcher.cpp
Comment thread src/video_frame.cpp
Comment thread src/video_frame.cpp
Comment thread build.sh
Copy link
Copy Markdown
Collaborator

@xianshijing-lk xianshijing-lk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment about the job.

Comment thread .github/workflows/builds.yml
Comment thread src/room_proto_converter.cpp
Comment thread src/stats.cpp Outdated
Copy link
Copy Markdown
Collaborator

@xianshijing-lk xianshijing-lk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm assuming you will address the comments.

Copy link
Copy Markdown
Contributor

@stephen-derosa stephen-derosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general this looks good, thanks for doing!

Comment thread .clang-tidy
@alan-george-lk alan-george-lk merged commit c457bd4 into main Apr 22, 2026
15 checks passed
@alan-george-lk alan-george-lk deleted the feature/clang-tidy branch April 22, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants