Skip to content

Commit

Permalink
More clang tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Aug 9, 2024
1 parent 6b38694 commit 38fb5c2
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Checks: >
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
performance-*,
-performance-avoid-endl,
readability-*,
-readability-avoid-nested-conditional-operator,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
Expand Down
4 changes: 2 additions & 2 deletions src/extension/NetworkController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ namespace extension {

private:
/// Our NUClearNetwork object that handles the networking
network::NUClearNetwork network{};
network::NUClearNetwork network;

/// The reaction that handles timed events from the network
ReactionHandle process_handle{};
ReactionHandle process_handle;
/// The reactions that listen for io
std::vector<ReactionHandle> listen_handles;

Expand Down
12 changes: 6 additions & 6 deletions src/extension/network/NUClearNetwork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace extension {
/// The socket address for the remote target
sock_t target{};
/// When we last received data from the remote target
std::chrono::steady_clock::time_point last_update{};
std::chrono::steady_clock::time_point last_update;
/// A list of the last n packet groups to be received
std::array<int, std::numeric_limits<uint8_t>::max()> recent_packets{};
/// An index for the recent_packets (circular buffer)
Expand All @@ -77,7 +77,7 @@ namespace extension {
/// Storage for fragmented packets while we build them
std::map<uint16_t,
std::pair<std::chrono::steady_clock::time_point, std::map<uint16_t, std::vector<uint8_t>>>>
assemblers{};
assemblers;

/// Struct storing the kalman filter for round trip time
struct RoundTripKF {
Expand Down Expand Up @@ -215,23 +215,23 @@ namespace extension {
PacketTarget(std::weak_ptr<NetworkTarget> target, std::vector<uint8_t> acked);

/// The target we are sending this packet to
std::weak_ptr<NetworkTarget> target{};
std::weak_ptr<NetworkTarget> target;

/// The bitset of the packets that have been acked
std::vector<uint8_t> acked;

/// When we last sent data to this client
std::chrono::steady_clock::time_point last_send{};
std::chrono::steady_clock::time_point last_send;
};

/// Default constructor for the PacketQueue
PacketQueue();

/// The remote targets that want this packet
std::list<PacketTarget> targets{};
std::list<PacketTarget> targets;

/// The header of the packet to send
DataPacket header{};
DataPacket header;

/// The data to send
std::vector<uint8_t> payload;
Expand Down
5 changes: 3 additions & 2 deletions src/threading/ReactionTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ namespace threading {
// Run our callback
callback(*this);
}
catch (...) {
catch (...) { // NOLINT(bugprone-empty-catch)
// This shouldn't happen, but either way no exceptions should ever leave this function
// They should have all been caught and callback is noexcept, however it seems that's a suggestion
// They should have all been caught and callback is noexcept
// However somehow it still happens sometimes so we need to catch it
}

// Restore the current task
Expand Down
2 changes: 1 addition & 1 deletion src/util/apply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace util {

// Get each of the values from the tuple, dereference them and call the function with them
// Also ensure that each value is a const reference
function(Dereferencer<decltype(std::get<S>(args))>(std::get<S>(args))...);
std::forward<Function>(function)(Dereferencer<decltype(std::get<S>(args))>(std::get<S>(args))...);
}

template <typename Function, typename... Arguments>
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/api/ReactorArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TestReactorNoArgs : public NUClear::Reactor {
public:
TestReactorNoArgs(std::unique_ptr<NUClear::Environment> environment) : NUClear::Reactor(std::move(environment)) {}

std::string s{};
std::string s;
bool b{false};
uint32_t i{0};
};
Expand All @@ -39,7 +39,7 @@ class TestReactorArgs : public NUClear::Reactor {
TestReactorArgs(std::unique_ptr<NUClear::Environment> environment, std::string s, const bool& b, const uint32_t& i)
: NUClear::Reactor(std::move(environment)), s(std::move(s)), b(b), i(i) {}

std::string s{};
std::string s;
bool b{false};
uint32_t i{0};
};
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/dsl/UDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace {
/// Events that occur during the test
std::vector<std::string> events; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

enum TestPorts {
enum TestPorts : uint16_t {
UNICAST_V4 = 40000,
UNICAST_V6 = 40001,
BROADCAST_V4 = 40002,
Expand Down Expand Up @@ -59,7 +59,7 @@ in_port_t broad_v4_port = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global
in_port_t multi_v4_port = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
in_port_t multi_v6_port = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

enum TestType {
enum TestType : uint8_t {
UNICAST_V4_KNOWN,
UNICAST_V4_EPHEMERAL,
UNICAST_V6_KNOWN,
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/threading/CountingLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace threading {
"The last lock to attempt a lock which hits the target value should obtain the lock"
"[threading][scheduler][CountingLock]") {

int base = GENERATE(-1, 1, 2);
int offset = GENERATE(-1, 0, 1);
const int base = GENERATE(-1, 1, 2);
const int offset = GENERATE(-1, 0, 1);

GIVEN("An atomic integer with a value of 2") {
std::atomic<int> active{2 * base + offset};
Expand Down

0 comments on commit 38fb5c2

Please sign in to comment.