mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[build] Fix Gradle compile_commands.json and clang-tidy warnings (#5977)
This commit is contained in:
42
.github/workflows/fix_compile_commands.py
vendored
Executable file
42
.github/workflows/fix_compile_commands.py
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Fix compile_commands.json generated by Gradle"
|
||||
)
|
||||
parser.add_argument("filename", help="compile_commands.json location")
|
||||
cmd_args = parser.parse_args()
|
||||
|
||||
# Read JSON
|
||||
with open(cmd_args.filename) as f:
|
||||
data = json.load(f)
|
||||
|
||||
for obj in data:
|
||||
out_args = []
|
||||
|
||||
# Filter out -isystem flags that cause false positives
|
||||
iter_args = iter(obj["arguments"])
|
||||
for arg in iter_args:
|
||||
if arg == "-isystem":
|
||||
next_arg = next(iter_args)
|
||||
|
||||
# /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include/xmmintrin.h:54:1:
|
||||
# error: conflicting types for '_mm_prefetch' [clang-diagnostic-error]
|
||||
if not next_arg.startswith("/usr/lib/gcc/"):
|
||||
out_args += ["-isystem", next_arg]
|
||||
else:
|
||||
out_args.append(arg)
|
||||
|
||||
obj["arguments"] = out_args
|
||||
|
||||
# Write JSON
|
||||
with open(cmd_args.filename, "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
5
.github/workflows/lint-format.yml
vendored
5
.github/workflows/lint-format.yml
vendored
@@ -68,7 +68,10 @@ jobs:
|
||||
- name: Install wpiformat
|
||||
run: pip3 install wpiformat
|
||||
- name: Create compile_commands.json
|
||||
run: ./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
|
||||
run: |
|
||||
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
|
||||
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64release/compile_commands.json
|
||||
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64debug/compile_commands.json
|
||||
- name: List changed files
|
||||
run: wpiformat -list-changed-files
|
||||
- name: Run clang-tidy release
|
||||
|
||||
@@ -89,6 +89,7 @@ void NetworkListener::Impl::Thread::Main() {
|
||||
std::memset(&addr, 0, sizeof(addr));
|
||||
addr.nl_family = AF_NETLINK;
|
||||
addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;
|
||||
// NOLINTNEXTLINE(modernize-avoid-bind)
|
||||
if (bind(sd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) < 0) {
|
||||
ERROR("NetworkListener: could not create socket: {}", std::strerror(errno));
|
||||
::close(sd);
|
||||
|
||||
@@ -99,8 +99,9 @@ WindowsMessagePump::WindowsMessagePump(
|
||||
|
||||
WindowsMessagePump::~WindowsMessagePump() {
|
||||
auto res = SendMessageA(hwnd, WM_CLOSE, NULL, NULL);
|
||||
if (m_mainThread.joinable())
|
||||
if (m_mainThread.joinable()) {
|
||||
m_mainThread.join();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsMessagePump::ThreadMain(HANDLE eventHandle) {
|
||||
|
||||
@@ -36,7 +36,6 @@ Checks:
|
||||
bugprone-unhandled-self-assignment,
|
||||
bugprone-unused-raii,
|
||||
bugprone-virtual-near-miss,
|
||||
cert-dcl58-cpp,
|
||||
cert-err52-cpp,
|
||||
cert-err60-cpp,
|
||||
cert-mem57-cpp,
|
||||
@@ -54,7 +53,6 @@ Checks:
|
||||
google-readability-avoid-underscore-in-googletest-name,
|
||||
google-readability-casting,
|
||||
google-runtime-operator,
|
||||
llvm-twine-local,
|
||||
misc-definitions-in-headers,
|
||||
misc-misplaced-const,
|
||||
misc-new-delete-overloads,
|
||||
|
||||
69
ntcore/.clang-tidy
Normal file
69
ntcore/.clang-tidy
Normal file
@@ -0,0 +1,69 @@
|
||||
Checks:
|
||||
'bugprone-assert-side-effect,
|
||||
bugprone-bool-pointer-implicit-conversion,
|
||||
bugprone-copy-constructor-init,
|
||||
bugprone-dangling-handle,
|
||||
bugprone-dynamic-static-initializers,
|
||||
bugprone-forwarding-reference-overload,
|
||||
bugprone-inaccurate-erase,
|
||||
bugprone-incorrect-roundings,
|
||||
bugprone-integer-division,
|
||||
bugprone-lambda-function-name,
|
||||
bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
bugprone-misplaced-widening-cast,
|
||||
bugprone-move-forwarding-reference,
|
||||
bugprone-multiple-statement-macro,
|
||||
bugprone-parent-virtual-call,
|
||||
bugprone-posix-return,
|
||||
bugprone-sizeof-container,
|
||||
bugprone-sizeof-expression,
|
||||
bugprone-spuriously-wake-up-functions,
|
||||
bugprone-string-constructor,
|
||||
bugprone-string-integer-assignment,
|
||||
bugprone-string-literal-with-embedded-nul,
|
||||
bugprone-suspicious-enum-usage,
|
||||
bugprone-suspicious-include,
|
||||
bugprone-suspicious-memset-usage,
|
||||
bugprone-suspicious-missing-comma,
|
||||
bugprone-suspicious-semicolon,
|
||||
bugprone-suspicious-string-compare,
|
||||
bugprone-throw-keyword-missing,
|
||||
bugprone-too-small-loop-variable,
|
||||
bugprone-undefined-memory-manipulation,
|
||||
bugprone-undelegated-constructor,
|
||||
bugprone-unhandled-self-assignment,
|
||||
bugprone-unused-raii,
|
||||
bugprone-virtual-near-miss,
|
||||
cert-err52-cpp,
|
||||
cert-err60-cpp,
|
||||
cert-mem57-cpp,
|
||||
cert-oop57-cpp,
|
||||
cert-oop58-cpp,
|
||||
clang-diagnostic-*,
|
||||
-clang-diagnostic-deprecated-declarations,
|
||||
-clang-diagnostic-#warnings,
|
||||
-clang-diagnostic-pedantic,
|
||||
clang-analyzer-*,
|
||||
cppcoreguidelines-slicing,
|
||||
google-build-namespaces,
|
||||
google-explicit-constructor,
|
||||
google-global-names-in-headers,
|
||||
google-readability-avoid-underscore-in-googletest-name,
|
||||
google-readability-casting,
|
||||
google-runtime-operator,
|
||||
misc-definitions-in-headers,
|
||||
misc-misplaced-const,
|
||||
misc-new-delete-overloads,
|
||||
misc-non-copyable-objects,
|
||||
modernize-avoid-bind,
|
||||
modernize-concat-nested-namespaces,
|
||||
modernize-make-shared,
|
||||
modernize-make-unique,
|
||||
modernize-pass-by-value,
|
||||
modernize-use-default-member-init,
|
||||
modernize-use-noexcept,
|
||||
modernize-use-nullptr,
|
||||
modernize-use-override,
|
||||
modernize-use-using,
|
||||
readability-braces-around-statements'
|
||||
FormatStyle: file
|
||||
@@ -609,6 +609,7 @@ void KeyboardJoystick::EditKey(const char* label, int* key) {
|
||||
void KeyboardJoystick::SettingsDisplay() {
|
||||
if (s_keyEdit) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
// NOLINTNEXTLINE(bugprone-sizeof-expression)
|
||||
for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); ++i) {
|
||||
if (io.KeysDown[i]) {
|
||||
// remove all other uses
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
using namespace frc;
|
||||
|
||||
void MotorController::SetVoltage(units::volt_t output) {
|
||||
// NOLINTNEXTLINE(bugprone-integer-division)
|
||||
Set(output / RobotController::GetBatteryVoltage());
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class SlewRateLimiter {
|
||||
m_negativeRateLimit{negativeRateLimit},
|
||||
m_prevVal{initialValue},
|
||||
m_prevTime{
|
||||
units::microsecond_t(wpi::math::MathSharedStore::GetTimestamp())} {}
|
||||
units::microsecond_t{wpi::math::MathSharedStore::GetTimestamp()}} {}
|
||||
|
||||
/**
|
||||
* Creates a new SlewRateLimiter with the given positive rate limit and
|
||||
|
||||
@@ -166,7 +166,7 @@ void SwerveDriveKinematics<NumModules>::DesaturateWheelSpeeds(
|
||||
auto k = units::math::max(translationalK, rotationalK);
|
||||
|
||||
auto scale = units::math::min(k * attainableMaxModuleSpeed / realMaxSpeed,
|
||||
units::scalar_t(1));
|
||||
units::scalar_t{1});
|
||||
for (auto& module : states) {
|
||||
module.speed = module.speed * scale;
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ int UDPClient::start(int port) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(modernize-avoid-bind)
|
||||
int result = bind(m_lsd, reinterpret_cast<sockaddr*>(&addr), sizeof(addr));
|
||||
if (result != 0) {
|
||||
WPI_ERROR(m_logger, "bind() failed: {}", SocketStrerror());
|
||||
|
||||
Reference in New Issue
Block a user