diff --git a/.clang-tidy b/.clang-tidy index cc5618e3..6b4c31f3 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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, diff --git a/src/extension/NetworkController.hpp b/src/extension/NetworkController.hpp index b91951f3..28080020 100644 --- a/src/extension/NetworkController.hpp +++ b/src/extension/NetworkController.hpp @@ -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 listen_handles; diff --git a/src/extension/network/NUClearNetwork.hpp b/src/extension/network/NUClearNetwork.hpp index 0c947d0e..88e56bdc 100644 --- a/src/extension/network/NUClearNetwork.hpp +++ b/src/extension/network/NUClearNetwork.hpp @@ -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::max()> recent_packets{}; /// An index for the recent_packets (circular buffer) @@ -77,7 +77,7 @@ namespace extension { /// Storage for fragmented packets while we build them std::map>>> - assemblers{}; + assemblers; /// Struct storing the kalman filter for round trip time struct RoundTripKF { @@ -215,23 +215,23 @@ namespace extension { PacketTarget(std::weak_ptr target, std::vector acked); /// The target we are sending this packet to - std::weak_ptr target{}; + std::weak_ptr target; /// The bitset of the packets that have been acked std::vector 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 targets{}; + std::list targets; /// The header of the packet to send - DataPacket header{}; + DataPacket header; /// The data to send std::vector payload; diff --git a/src/threading/ReactionTask.cpp b/src/threading/ReactionTask.cpp index 9d8a2d43..dcc00315 100644 --- a/src/threading/ReactionTask.cpp +++ b/src/threading/ReactionTask.cpp @@ -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 diff --git a/src/util/apply.hpp b/src/util/apply.hpp index ac85caab..56664ca2 100644 --- a/src/util/apply.hpp +++ b/src/util/apply.hpp @@ -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(args))>(std::get(args))...); + std::forward(function)(Dereferencer(args))>(std::get(args))...); } template diff --git a/tests/tests/api/ReactorArgs.cpp b/tests/tests/api/ReactorArgs.cpp index 533e2bc7..bb983755 100644 --- a/tests/tests/api/ReactorArgs.cpp +++ b/tests/tests/api/ReactorArgs.cpp @@ -30,7 +30,7 @@ class TestReactorNoArgs : public NUClear::Reactor { public: TestReactorNoArgs(std::unique_ptr environment) : NUClear::Reactor(std::move(environment)) {} - std::string s{}; + std::string s; bool b{false}; uint32_t i{0}; }; @@ -39,7 +39,7 @@ class TestReactorArgs : public NUClear::Reactor { TestReactorArgs(std::unique_ptr 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}; }; diff --git a/tests/tests/dsl/UDP.cpp b/tests/tests/dsl/UDP.cpp index df9081af..e9633d5a 100644 --- a/tests/tests/dsl/UDP.cpp +++ b/tests/tests/dsl/UDP.cpp @@ -31,7 +31,7 @@ namespace { /// Events that occur during the test std::vector events; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -enum TestPorts { +enum TestPorts : uint16_t { UNICAST_V4 = 40000, UNICAST_V6 = 40001, BROADCAST_V4 = 40002, @@ -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, diff --git a/tests/tests/threading/CountingLock.cpp b/tests/tests/threading/CountingLock.cpp index 22984ae9..01a9ab52 100644 --- a/tests/tests/threading/CountingLock.cpp +++ b/tests/tests/threading/CountingLock.cpp @@ -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 active{2 * base + offset};