Skip to content

Commit 70a1b5f

Browse files
committed
clang-tidy fixes
Signed-off-by: Joel Winarske <joel.winarske@gmail.com>
1 parent 19789ab commit 70a1b5f

File tree

27 files changed

+205
-218
lines changed

27 files changed

+205
-218
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,55 +94,77 @@ jobs:
9494

9595
- name: Install dependencies
9696
run: |
97+
# Install LLVM 19 with libc++
98+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
99+
sudo tee /etc/apt/trusted.gpg.d/llvm.asc
100+
sudo add-apt-repository -y \
101+
'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main'
97102
sudo apt-get update
98103
sudo apt-get install -y \
99-
clang-tidy \
100-
gcc-14 \
101-
g++-14 \
104+
clang-19 \
105+
clang-tidy-19 \
106+
llvm-19 \
107+
llvm-19-dev \
108+
lld-19 \
109+
libc++-19-dev \
110+
libc++abi-19-dev \
102111
cmake \
103112
ninja-build \
104113
libudev-dev \
105114
libsystemd-dev \
106115
pkg-config
107116
108-
- name: Cache clang-tidy results
109-
uses: actions/cache@v4
110-
with:
111-
path: .clang-tidy-cache
112-
key: >-
113-
clang-tidy-${{ runner.os }}-${{
114-
hashFiles('**/*.cpp', '**/*.cc', '**/*.h', '**/*.hpp',
115-
'.clang-tidy') }}
116-
restore-keys: |
117-
clang-tidy-${{ runner.os }}-
118-
119117
- name: Configure CMake for clang-tidy
120118
run: |
121119
mkdir -p build
122120
cd build
123121
cmake .. -GNinja \
124122
-DCMAKE_BUILD_TYPE=Release \
125-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
123+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
124+
-DCMAKE_CXX_FLAGS="-stdlib=libc++" \
125+
-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++abi" \
126+
-DLLVM_CONFIG=/usr/bin/llvm-config-19
127+
128+
sed -i \
129+
-e 's/-fdeps-format=p1689r5//g' \
130+
-e 's/-fmodules-ts//g' \
131+
-e 's/-fmodule-mapper=[^ ]*//g' \
132+
-e 's/@[^ ]*\.modmap//g' \
133+
compile_commands.json
134+
126135
env:
127-
CC: gcc-14
128-
CXX: g++-14
136+
CC: clang-19
137+
CXX: clang++-19
129138

130139
- name: Run clang-tidy
131140
run: |
132-
# Create cache directory if it doesn't exist
133-
mkdir -p .clang-tidy-cache
134-
135141
# Find all C++ source files and run clang-tidy
136142
# Exclude third_party directory from analysis
137-
find src -type f \( -name "*.cpp" -o -name "*.cc" \) | \
138-
while read file; do
139-
echo "Analyzing $file..."
140-
clang-tidy "$file" \
141-
-p build \
142-
--warnings-as-errors='*' \
143-
--header-filter='^(?!.*third_party).*$' \
144-
--system-headers=false || exit 1
145-
done
143+
export FILE_LIST=$(find src -type d -name third_party -prune -false -o -name '*.cc' -o -name '*.hpp' -o -name '*.h')
144+
145+
clang-tidy-19 --version
146+
clang-tidy-19 --help
147+
148+
clang-tidy-19 \
149+
-p build \
150+
-export-fixes=tidy-results-suggested-fixes.txt \
151+
-extra-arg='-Ithird_party/glaze/include' \
152+
-extra-arg='-Ithird_party/sdbus-cpp/include' \
153+
-extra-arg='-Ithird_party/spdlog/include' \
154+
-warnings-as-errors='*' \
155+
-header-filter='^(?!.*third_party).*$' \
156+
--dump-config
157+
158+
run-clang-tidy-19 \
159+
-p build \
160+
-export-fixes=tidy-results-suggested-fixes.txt \
161+
-extra-arg='-Ithird_party/glaze/include' \
162+
-extra-arg='-Ithird_party/sdbus-cpp/include' \
163+
-extra-arg='-Ithird_party/spdlog/include' \
164+
-warnings-as-errors='*' \
165+
-header-filter='^(?!.*third_party).*$' \
166+
$FILE_LIST
167+
146168
shell: bash
147169

148170
build:
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
<node>
22
<interface name="org.freedesktop.ModemManager1">
33
<method name="ScanDevices"/>
4-
<method name="SetLogging"><arg type="s" name="level" direction="in"/></method>
5-
<method name="ReportKernelEvent"><arg type="a{sv}" name="properties" direction="in"/></method>
6-
<method name="InhibitDevice"><arg type="s" name="uid" direction="in"/><arg type="b" name="inhibit" direction="in"/></method>
7-
<property type="s" name="Version" access="read"/></interface>
4+
<method name="SetLogging">
5+
<arg type="s" name="level" direction="in"/>
6+
</method>
7+
<method name="ReportKernelEvent">
8+
<arg type="a{sv}" name="properties" direction="in"/>
9+
</method>
10+
<method name="InhibitDevice">
11+
<arg type="s" name="uid" direction="in"/>
12+
<arg type="b" name="inhibit" direction="in"/>
13+
</method>
14+
<property type="s" name="Version" access="read"/>
15+
</interface>
816
</node>

src/bluez/horipad_steam/input_reader.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ InputReader::~InputReader() {
4040
stop();
4141
}
4242

43+
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
4344
InputReader::Task InputReader::read_input() {
4445
spdlog::debug("hidraw device: {}", device_);
4546

@@ -137,7 +138,7 @@ InputReader::Task InputReader::read_input() {
137138
close(fd);
138139
stop();
139140

140-
co_return;
141+
co_return; // NOLINT(readability-static-accessed-through-instance)
141142
}
142143

143144
std::string InputReader::dpad_to_string(const Direction dpad) {

src/bluez/ps5_dual_sense/input_reader.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ InputReader::~InputReader() {
4141
stop();
4242
}
4343

44+
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
4445
InputReader::Task InputReader::read_input() {
4546
spdlog::debug("hidraw device: {}", device_);
4647

@@ -142,7 +143,7 @@ InputReader::Task InputReader::read_input() {
142143
close(fd);
143144
stop();
144145

145-
co_return;
146+
co_return; // NOLINT(readability-static-accessed-through-instance)
146147
}
147148

148149
int InputReader::GetControllerMacAll(const int fd,

src/bluez/xbox_controller/input_reader.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ InputReader::~InputReader() {
4040
stop();
4141
}
4242

43+
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
4344
InputReader::Task InputReader::read_input() {
4445
spdlog::debug("hidraw device: {}", device_);
4546

@@ -133,7 +134,7 @@ InputReader::Task InputReader::read_input() {
133134
close(fd);
134135
stop();
135136

136-
co_return;
137+
co_return; // NOLINT(readability-static-accessed-through-instance)
137138
}
138139

139140
std::string InputReader::dpad_to_string(const Direction dpad) {

src/geoclue2/geoclue2_manager.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
#include "../utils/utils.h"
1818

19-
GeoClue2Manager::GeoClue2Manager(sdbus::IConnection& connection,
20-
LocationPropertiesChangedCallback callback)
19+
GeoClue2Manager::GeoClue2Manager(
20+
sdbus::IConnection& connection,
21+
const LocationPropertiesChangedCallback& callback)
2122
: ProxyInterfaces{connection, sdbus::ServiceName(kBusName),
2223
sdbus::ObjectPath(kObjectPath)},
2324
object_path_(sdbus::ObjectPath(kObjectPath)) {

src/geoclue2/geoclue2_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class GeoClue2Manager final
3333

3434
explicit GeoClue2Manager(
3535
sdbus::IConnection& connection,
36-
LocationPropertiesChangedCallback callback = nullptr);
36+
const LocationPropertiesChangedCallback& callback = nullptr);
3737

3838
virtual ~GeoClue2Manager();
3939

src/login1/login1_manager_client.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
#include "login1_manager_client.h"
1616

17-
#include <sys/socket.h>
18-
1917
#include "../utils/utils.h"
2018

2119
Login1ManagerClient::Login1ManagerClient(sdbus::IConnection& connection)
@@ -25,7 +23,7 @@ Login1ManagerClient::Login1ManagerClient(sdbus::IConnection& connection)
2523
const auto props = this->GetAllAsync(
2624
Manager_proxy::INTERFACE_NAME,
2725
[&](std::optional<sdbus::Error> error,
28-
std::map<sdbus::PropertyName, sdbus::Variant> values) {
26+
const std::map<sdbus::PropertyName, sdbus::Variant>& values) {
2927
if (!error) {
3028
onPropertiesChanged(
3129
sdbus::InterfaceName(Manager_proxy::INTERFACE_NAME), values, {});
@@ -60,19 +58,19 @@ Login1ManagerClient::Login1ManagerClient(sdbus::IConnection& connection)
6058

6159
Login1ManagerClient::~Login1ManagerClient() {
6260
unregisterProxy();
63-
for (const auto& [objectPath, seat] : seats_) {
61+
for (const auto& objectPath : seats_ | std::views::keys) {
6462
if (seats_.contains(objectPath)) {
6563
seats_[objectPath].reset();
6664
seats_.erase(objectPath);
6765
}
6866
}
69-
for (const auto& [objectPath, session] : sessions_) {
67+
for (const auto& objectPath : sessions_ | std::views::keys) {
7068
if (sessions_.contains(objectPath)) {
7169
sessions_[objectPath].reset();
7270
sessions_.erase(objectPath);
7371
}
7472
}
75-
for (const auto& [objectPath, seat] : users_) {
73+
for (const auto& objectPath : users_ | std::views::keys) {
7674
if (users_.contains(objectPath)) {
7775
users_[objectPath].reset();
7876
users_.erase(objectPath);

src/network1/network1_client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Network1ManagerClient::Network1ManagerClient(sdbus::IConnection& connection)
1212
this->GetAllAsync(
1313
Manager_proxy::INTERFACE_NAME,
1414
[this](std::optional<sdbus::Error> error,
15-
std::map<sdbus::PropertyName, sdbus::Variant> values) {
15+
const std::map<sdbus::PropertyName, sdbus::Variant>& values) {
1616
if (error) {
1717
spdlog::warn("network1.Manager GetAllAsync failed: {} - {}",
1818
error->getName(), error->getMessage());

src/proxy/fi/w1/wpa_supplicant1/wpa_supplicant1_proxy.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@
33
* This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT!
44
*/
55

6-
#ifndef __sdbuscpp__src_proxy_fi_w1_wpa_supplicant1_wpa_supplicant1_proxy_h__proxy__H__
7-
#define __sdbuscpp__src_proxy_fi_w1_wpa_supplicant1_wpa_supplicant1_proxy_h__proxy__H__
6+
#ifndef _sdbuscpp_src_proxy_fi_w1_wpa_supplicant1_wpa_supplicant1_proxy_h_proxy_H_
7+
#define _sdbuscpp_src_proxy_fi_w1_wpa_supplicant1_wpa_supplicant1_proxy_h_proxy_H_
88

99
#include <sdbus-c++/sdbus-c++.h>
1010
#include <string>
1111
#include <tuple>
1212

13-
namespace fi {
14-
namespace w1 {
13+
namespace fi::w1 {
1514

1615
class wpa_supplicant1_proxy {
1716
public:
18-
static constexpr const char* INTERFACE_NAME = "fi.w1.wpa_supplicant1";
19-
20-
protected:
21-
wpa_supplicant1_proxy(sdbus::IProxy& proxy) : m_proxy(proxy) {}
17+
static constexpr auto INTERFACE_NAME = "fi.w1.wpa_supplicant1";
2218

2319
wpa_supplicant1_proxy(const wpa_supplicant1_proxy&) = delete;
2420
wpa_supplicant1_proxy& operator=(const wpa_supplicant1_proxy&) = delete;
2521
wpa_supplicant1_proxy(wpa_supplicant1_proxy&&) = delete;
2622
wpa_supplicant1_proxy& operator=(wpa_supplicant1_proxy&&) = delete;
2723

24+
protected:
25+
explicit wpa_supplicant1_proxy(sdbus::IProxy& proxy) : m_proxy(proxy) {}
26+
2827
~wpa_supplicant1_proxy() = default;
2928

3029
void registerProxy() {
@@ -152,7 +151,6 @@ class wpa_supplicant1_proxy {
152151
sdbus::IProxy& m_proxy;
153152
};
154153

155-
} // namespace w1
156-
} // namespace fi
154+
} // namespace fi::w1
157155

158156
#endif

0 commit comments

Comments
 (0)