Finish clang-tidy cleanups (#3003)

* Add .clang-tidy configuration.
* A separate .clang-tidy is used for hal includes to suppress modernize-use-using
  (as these are C headers).
* Add NOLINT where necessary for a clean run.
* Add clang-tidy job to lint-format workflow.  This workflow is now only run on PRs.
  To reduce runtime, clang-tidy is only run on files changed in the PR.

Two wpilibc changes; both are unlikely to break user code:
* BuiltInAccelerometer: Make SetRange() final
* Counter: Make SetMaxPeriod() final

After these cleanups, the only file that does not run cleanly is
cscore_raw_cv.h due to it not being standalone.
This commit is contained in:
Peter Johnson
2021-01-01 10:27:49 -08:00
committed by GitHub
parent d741101fe3
commit f5e0fc3e9a
49 changed files with 314 additions and 138 deletions

View File

@@ -448,10 +448,10 @@ void DispatcherBase::ServerThreadMain() {
using namespace std::placeholders;
auto conn = std::make_shared<NetworkConnection>(
++m_connections_uid, std::move(stream), m_notifier, m_logger,
std::bind(&Dispatcher::ServerHandshake, this, _1, _2, _3),
std::bind(&IStorage::GetMessageEntryType, &m_storage, _1));
std::bind(&Dispatcher::ServerHandshake, this, _1, _2, _3), // NOLINT
std::bind(&IStorage::GetMessageEntryType, &m_storage, _1)); // NOLINT
conn->set_process_incoming(
std::bind(&IStorage::ProcessIncoming, &m_storage, _1, _2,
std::bind(&IStorage::ProcessIncoming, &m_storage, _1, _2, // NOLINT
std::weak_ptr<NetworkConnection>(conn)));
{
std::scoped_lock lock(m_user_mutex);
@@ -507,10 +507,10 @@ void DispatcherBase::ClientThreadMain() {
using namespace std::placeholders;
auto conn = std::make_shared<NetworkConnection>(
++m_connections_uid, std::move(stream), m_notifier, m_logger,
std::bind(&Dispatcher::ClientHandshake, this, _1, _2, _3),
std::bind(&IStorage::GetMessageEntryType, &m_storage, _1));
std::bind(&Dispatcher::ClientHandshake, this, _1, _2, _3), // NOLINT
std::bind(&IStorage::GetMessageEntryType, &m_storage, _1)); // NOLINT
conn->set_process_incoming(
std::bind(&IStorage::ProcessIncoming, &m_storage, _1, _2,
std::bind(&IStorage::ProcessIncoming, &m_storage, _1, _2, // NOLINT
std::weak_ptr<NetworkConnection>(conn)));
m_connections.resize(0); // disconnect any current
m_connections.emplace_back(conn);

View File

@@ -15,7 +15,8 @@ using namespace std::placeholders;
InstanceImpl::InstanceImpl(int inst)
: logger_impl(inst),
logger(std::bind(&LoggerImpl::Log, &logger_impl, _1, _2, _3, _4)),
logger(
std::bind(&LoggerImpl::Log, &logger_impl, _1, _2, _3, _4)), // NOLINT
connection_notifier(inst),
entry_notifier(inst, logger),
rpc_server(inst, logger),

View File

@@ -376,4 +376,4 @@ void NetworkConnection::PostOutgoing(bool keep_alive) {
m_pending_update.resize(0);
}
m_last_post = now;
}
} // NOLINT

View File

@@ -59,21 +59,21 @@ class NetworkConnection : public INetworkConnection {
void Start();
void Stop();
ConnectionInfo info() const override;
ConnectionInfo info() const final;
bool active() const { return m_active; }
wpi::NetworkStream& stream() { return *m_stream; }
void QueueOutgoing(std::shared_ptr<Message> msg) override;
void QueueOutgoing(std::shared_ptr<Message> msg) final;
void PostOutgoing(bool keep_alive) override;
unsigned int uid() const { return m_uid; }
unsigned int proto_rev() const override;
void set_proto_rev(unsigned int proto_rev) override;
unsigned int proto_rev() const final;
void set_proto_rev(unsigned int proto_rev) final;
State state() const override;
void set_state(State state) override;
State state() const final;
void set_state(State state) final;
std::string remote_id() const;
void set_remote_id(StringRef remote_id);

View File

@@ -19,7 +19,7 @@ using namespace nt;
static void ConvertToC(wpi::StringRef in, char** out) {
*out = static_cast<char*>(wpi::safe_malloc(in.size() + 1));
std::memmove(*out, in.data(), in.size());
std::memmove(*out, in.data(), in.size()); // NOLINT
(*out)[in.size()] = '\0';
}
@@ -558,7 +558,7 @@ NT_Value** NT_UnpackRpcValues(const char* packed, size_t packed_len,
// create array and copy into it
NT_Value** values = static_cast<NT_Value**>(
wpi::safe_malloc(values_v.size() * sizeof(NT_Value*)));
wpi::safe_malloc(values_v.size() * sizeof(NT_Value*))); // NOLINT
for (size_t i = 0; i < values_v.size(); ++i) {
values[i] = static_cast<NT_Value*>(wpi::safe_malloc(sizeof(NT_Value)));
ConvertToC(*values_v[i], values[i]);