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

@@ -19,7 +19,7 @@ class ExternalLimitSwitch : public Switch {
explicit ExternalLimitSwitch(sdf::ElementPtr sdf);
/// \brief Returns true when the switch is triggered.
virtual bool Get();
bool Get() override;
private:
gazebo::sensors::ContactSensorPtr sensor;

View File

@@ -18,7 +18,7 @@ class InternalLimitSwitch : public Switch {
InternalLimitSwitch(gazebo::physics::ModelPtr model, sdf::ElementPtr sdf);
/// \brief Returns true when the switch is triggered.
virtual bool Get();
bool Get() override;
private:
gazebo::physics::JointPtr joint;

View File

@@ -7,7 +7,7 @@
class DSCommPacketTest : public ::testing::Test {
public:
DSCommPacketTest() {}
DSCommPacketTest() = default;
void SendJoysticks() { commPacket.SendJoysticks(); }

View File

@@ -1295,7 +1295,7 @@ static void DisplaySystemJoystick(SystemJoystick& joy, int i) {
// drag and drop sources are the low level joysticks
if (ImGui::BeginDragDropSource()) {
SystemJoystick* joyPtr = &joy;
ImGui::SetDragDropPayload("Joystick", &joyPtr, sizeof(joyPtr));
ImGui::SetDragDropPayload("Joystick", &joyPtr, sizeof(joyPtr)); // NOLINT
ImGui::Text("%d: %s", i, joy.GetName());
ImGui::EndDragDropSource();
}
@@ -1325,7 +1325,8 @@ static void DisplayJoysticks() {
if (!disableDS && joy.sys) {
ImGui::Selectable(label, false);
if (ImGui::BeginDragDropSource()) {
ImGui::SetDragDropPayload("Joystick", &joy.sys, sizeof(joy.sys));
ImGui::SetDragDropPayload("Joystick", &joy.sys,
sizeof(joy.sys)); // NOLINT
ImGui::Text("%d: %s", joy.sys->GetIndex(), joy.sys->GetName());
ImGui::EndDragDropSource();
}
@@ -1335,7 +1336,7 @@ static void DisplayJoysticks() {
if (!disableDS && ImGui::BeginDragDropTarget()) {
if (const ImGuiPayload* payload =
ImGui::AcceptDragDropPayload("Joystick")) {
IM_ASSERT(payload->DataSize == sizeof(SystemJoystick*));
IM_ASSERT(payload->DataSize == sizeof(SystemJoystick*)); // NOLINT
SystemJoystick* payload_sys =
*static_cast<SystemJoystick* const*>(payload->Data);
// clear it from the other joysticks

View File

@@ -16,11 +16,11 @@
namespace wpilibws {
typedef void (*HALCbRegisterIndexedFunc)(int32_t index,
HAL_NotifyCallback callback,
using HALCbRegisterIndexedFunc = void (*)(int32_t index,
HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify);
using HALCbRegisterSingleFunc = void (*)(HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify);
typedef void (*HALCbRegisterSingleFunc)(HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify);
// provider generates diffs based on values
class HALSimWSHalProvider : public HALSimWSBaseProvider {

View File

@@ -12,7 +12,7 @@ class HALSimWSProviderAddressableLED : public HALSimWSHalChanProvider {
static void Initialize(WSRegisterFunc webRegisterFunc);
using HALSimWSHalChanProvider::HALSimWSHalChanProvider;
~HALSimWSProviderAddressableLED();
~HALSimWSProviderAddressableLED() override;
protected:
void RegisterCallbacks() override;

View File

@@ -21,7 +21,7 @@ class HALSimWSProviderAnalogIn : public HALSimWSHalChanProvider {
protected:
void RegisterCallbacks() override;
void CancelCallbacks() override;
void CancelCallbacks() final;
void DoCancelCallbacks();
private:
@@ -45,7 +45,7 @@ class HALSimWSProviderAnalogOut : public HALSimWSHalChanProvider {
protected:
void RegisterCallbacks() override;
void CancelCallbacks() override;
void CancelCallbacks() final;
void DoCancelCallbacks();
private:

View File

@@ -14,7 +14,7 @@ class HALSimWSProviderPCM : public HALSimWSHalChanProvider {
static void Initialize(WSRegisterFunc webRegisterFunc);
using HALSimWSHalChanProvider::HALSimWSHalChanProvider;
~HALSimWSProviderPCM();
~HALSimWSProviderPCM() override;
protected:
void RegisterCallbacks() override;

View File

@@ -16,7 +16,7 @@ class HALSimWSProviderSolenoid : public HALSimWSHalProvider {
explicit HALSimWSProviderSolenoid(int32_t pcmChannel, int32_t solenoidChannel,
const std::string& key,
const std::string& type);
~HALSimWSProviderSolenoid();
~HALSimWSProviderSolenoid() override;
protected:
void RegisterCallbacks() override;