diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..9ba6b95df1 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,76 @@ +Checks: + 'bugprone-assert-side-effect, + bugprone-bool-pointer-implicit-conversion, + bugprone-copy-constructor-init, + bugprone-dangling-handle, + bugprone-dynamic-static-initializers, + bugprone-exception-escape, + bugprone-forward-declaration-namespace, + 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-dcl58-cpp, + 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, + llvm-twine-local, + 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 +CheckOptions: + - key: bugprone-dangling-handle + value: 'wpi::StringRef;wpi::Twine' diff --git a/.github/workflows/lint-format.yml b/.github/workflows/lint-format.yml index 3e63438124..ca26eb2684 100644 --- a/.github/workflows/lint-format.yml +++ b/.github/workflows/lint-format.yml @@ -1,6 +1,6 @@ name: Lint and Format -on: [pull_request, push] +on: [pull_request] jobs: wpiformat: @@ -18,10 +18,35 @@ jobs: with: python-version: 3.8 - name: Install clang-format - run: sudo apt-get update -q && sudo apt-get install clang-format-10 + run: sudo apt-get update -q && sudo apt-get install -y clang-format-10 - name: Install wpiformat run: pip3 install wpiformat - name: Run run: wpiformat -clang 10 - name: Check Output run: git --no-pager diff --exit-code HEAD + tidy: + name: "clang-tidy" + runs-on: ubuntu-latest + container: wpilib/roborio-cross-ubuntu:2020-18.04 + steps: + - uses: actions/checkout@v2 + - name: Fetch all history and metadata + run: | + git fetch --prune --unshallow + git checkout -b pr + git branch -f master origin/master + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install clang-format and clang-tidy + run: sudo apt-get update -q && sudo apt-get install -y clang-format-10 clang-tidy-10 + - name: Install wpiformat + run: pip3 install wpiformat + - name: Create compile_commands.json + run: mkdir build-cmake && cd build-cmake && cmake -DWITH_OLD_COMMANDS=ON -DWITH_EXAMPLES=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=YES .. + - name: List changed files + run: wpiformat -list-changed-files + - name: Run clang-tidy + run: wpiformat -clang 10 -no-format -tidy-changed -compile-commands=build-cmake diff --git a/cscore/src/main/native/cpp/JpegUtil.cpp b/cscore/src/main/native/cpp/JpegUtil.cpp index 61c358153a..0ec9eee375 100644 --- a/cscore/src/main/native/cpp/JpegUtil.cpp +++ b/cscore/src/main/native/cpp/JpegUtil.cpp @@ -65,12 +65,11 @@ bool GetJpegSize(wpi::StringRef data, int* width, int* height) { } data = data.substr(2); // Get to the first block - auto bytes = data.bytes_begin(); for (;;) { if (data.size() < 4) { return false; // EOF } - bytes = data.bytes_begin(); + auto bytes = data.bytes_begin(); if (bytes[0] != 0xff) { return false; // not a tag } @@ -104,12 +103,11 @@ bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) { // Search until SOS for DHT tag sdata = sdata.substr(2); // Get to the first block - auto bytes = sdata.bytes_begin(); for (;;) { if (sdata.size() < 4) { return false; // EOF } - bytes = sdata.bytes_begin(); + auto bytes = sdata.bytes_begin(); if (bytes[0] != 0xff) { return false; // not a tag } diff --git a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp index 4b0f02c3d0..911432549a 100644 --- a/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp +++ b/cscore/src/main/native/cpp/jni/CameraServerJNI.cpp @@ -184,7 +184,7 @@ class JCSGlobal { jvm->DetachCurrentThread(); } } - operator T() { return m_obj; } + operator T() { return m_obj; } // NOLINT T obj() { return m_obj; } private: diff --git a/cscore/src/main/native/windows/ComPtr.h b/cscore/src/main/native/windows/ComPtr.h index ac79bb3adb..2d9f241b5d 100644 --- a/cscore/src/main/native/windows/ComPtr.h +++ b/cscore/src/main/native/windows/ComPtr.h @@ -30,18 +30,18 @@ class ComPtr { } template - ComPtr(const ComPtr& other) noexcept : m_ptr(other.m_ptr) { + ComPtr(const ComPtr& other) noexcept : m_ptr(other.m_ptr) { // NOLINT InternalAddRef(); } template - ComPtr(ComPtr&& other) noexcept : m_ptr(other.m_ptr) { + ComPtr(ComPtr&& other) noexcept : m_ptr(other.m_ptr) { // NOLINT other.m_ptr = nullptr; } ~ComPtr() noexcept { InternalRelease(); } - ComPtr& operator=(const ComPtr& other) noexcept { + ComPtr& operator=(const ComPtr& other) noexcept { // NOLINT InternalCopy(other.m_ptr); return *this; } diff --git a/glass/src/lib/native/cpp/DataSource.cpp b/glass/src/lib/native/cpp/DataSource.cpp index 56c7f37ef7..ab304fe63d 100644 --- a/glass/src/lib/native/cpp/DataSource.cpp +++ b/glass/src/lib/native/cpp/DataSource.cpp @@ -139,7 +139,7 @@ bool DataSource::InputInt(const char* label, int* v, int step, int step_fast, void DataSource::EmitDrag(ImGuiDragDropFlags flags) const { if (ImGui::BeginDragDropSource(flags)) { auto self = this; - ImGui::SetDragDropPayload("DataSource", &self, sizeof(self)); + ImGui::SetDragDropPayload("DataSource", &self, sizeof(self)); // NOLINT const char* name = GetName(); ImGui::TextUnformatted(name[0] == '\0' ? m_id.c_str() : name); ImGui::EndDragDropSource(); diff --git a/glass/src/lib/native/cpp/other/Log.cpp b/glass/src/lib/native/cpp/other/Log.cpp index 5c6fe2809f..83bbe3778f 100644 --- a/glass/src/lib/native/cpp/other/Log.cpp +++ b/glass/src/lib/native/cpp/other/Log.cpp @@ -9,6 +9,8 @@ using namespace glass; +LogData::LogData(size_t maxLines) : m_maxLines{maxLines} {} + void LogData::Clear() { m_buf.clear(); m_lineOffsets.clear(); diff --git a/glass/src/lib/native/include/glass/other/Log.h b/glass/src/lib/native/include/glass/other/Log.h index 316f61f565..3d1ab146a1 100644 --- a/glass/src/lib/native/include/glass/other/Log.h +++ b/glass/src/lib/native/include/glass/other/Log.h @@ -16,7 +16,7 @@ class LogData { friend void DisplayLog(LogData*, bool); public: - explicit LogData(size_t maxLines = 10000) : m_maxLines{maxLines} {} + explicit LogData(size_t maxLines = 10000); void Clear(); void Append(const wpi::Twine& msg); diff --git a/hal/src/main/native/athena/HALInitializer.h b/hal/src/main/native/athena/HALInitializer.h index eb7fbafd8a..8a96e292cc 100644 --- a/hal/src/main/native/athena/HALInitializer.h +++ b/hal/src/main/native/athena/HALInitializer.h @@ -6,11 +6,10 @@ #include -namespace hal { -namespace init { +namespace hal::init { extern std::atomic_bool HAL_IsInitialized; extern void RunInitialize(); -static inline void CheckInit() { +inline void CheckInit() { if (HAL_IsInitialized.load(std::memory_order_relaxed)) { return; } @@ -52,5 +51,4 @@ extern void InitializeSerialPort(); extern void InitializeSolenoid(); extern void InitializeSPI(); extern void InitializeThreads(); -} // namespace init -} // namespace hal +} // namespace hal::init diff --git a/hal/src/main/native/athena/cpp/SerialHelper.cpp b/hal/src/main/native/athena/cpp/SerialHelper.cpp index 012d9a0b5b..3e0a3d81db 100644 --- a/hal/src/main/native/athena/cpp/SerialHelper.cpp +++ b/hal/src/main/native/athena/cpp/SerialHelper.cpp @@ -155,7 +155,7 @@ void SerialHelper::CoiteratedSort( } } } - vec = sortedVec; + vec.swap(sortedVec); } void SerialHelper::QueryHubPaths(int32_t* status) { diff --git a/hal/src/main/native/include/hal/.clang-tidy b/hal/src/main/native/include/hal/.clang-tidy new file mode 100644 index 0000000000..a7388ad83d --- /dev/null +++ b/hal/src/main/native/include/hal/.clang-tidy @@ -0,0 +1,75 @@ +Checks: + 'bugprone-assert-side-effect, + bugprone-bool-pointer-implicit-conversion, + bugprone-copy-constructor-init, + bugprone-dangling-handle, + bugprone-dynamic-static-initializers, + bugprone-exception-escape, + bugprone-forward-declaration-namespace, + 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-dcl58-cpp, + 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, + llvm-twine-local, + 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, + readability-braces-around-statements' +FormatStyle: file +CheckOptions: + - key: bugprone-dangling-handle + value: 'wpi::StringRef;wpi::Twine' diff --git a/hal/src/main/native/include/hal/handles/HandlesInternal.h b/hal/src/main/native/include/hal/handles/HandlesInternal.h index 7c15d034d7..6a50ca1fb3 100644 --- a/hal/src/main/native/include/hal/handles/HandlesInternal.h +++ b/hal/src/main/native/include/hal/handles/HandlesInternal.h @@ -125,9 +125,8 @@ static inline bool isHandleCorrectVersion(HAL_Handle handle, int16_t version) { * @return true if the handle is proper version and type, otherwise * false. */ -static inline int16_t getHandleTypedIndex(HAL_Handle handle, - HAL_HandleEnum enumType, - int16_t version) { +inline int16_t getHandleTypedIndex(HAL_Handle handle, HAL_HandleEnum enumType, + int16_t version) { if (!isHandleType(handle, enumType)) { return InvalidHandleIndex; } @@ -155,7 +154,7 @@ static inline int16_t getHandleTypedIndex(HAL_Handle handle, * @param handle the port handle * @return the port channel */ -static inline int16_t getPortHandleChannel(HAL_PortHandle handle) { +inline int16_t getPortHandleChannel(HAL_PortHandle handle) { if (!isHandleType(handle, HAL_HandleEnum::Port)) { return InvalidHandleIndex; } @@ -169,7 +168,7 @@ static inline int16_t getPortHandleChannel(HAL_PortHandle handle) { * @param handle the port handle * @return the port module */ -static inline int16_t getPortHandleModule(HAL_PortHandle handle) { +inline int16_t getPortHandleModule(HAL_PortHandle handle) { if (!isHandleType(handle, HAL_HandleEnum::Port)) { return InvalidHandleIndex; } @@ -183,7 +182,7 @@ static inline int16_t getPortHandleModule(HAL_PortHandle handle) { * @param handle the port handle * @return the port SPI channel */ -static inline int16_t getPortHandleSPIEnable(HAL_PortHandle handle) { +inline int16_t getPortHandleSPIEnable(HAL_PortHandle handle) { if (!isHandleType(handle, HAL_HandleEnum::Port)) { return InvalidHandleIndex; } diff --git a/hal/src/main/native/sim/ErrorsInternal.h b/hal/src/main/native/sim/ErrorsInternal.h index 29a36b694a..eb2bf8c3d2 100644 --- a/hal/src/main/native/sim/ErrorsInternal.h +++ b/hal/src/main/native/sim/ErrorsInternal.h @@ -108,104 +108,104 @@ typedef enum { * Represents the resulting status of a function call through its return value. * 0 is success, negative values are errors, and positive values are warnings. */ -typedef int32_t NiFpga_Status; +typedef int32_t NiFpga_Status; // NOLINT /** * No errors or warnings. */ -static const NiFpga_Status NiFpga_Status_Success = 0; +constexpr NiFpga_Status NiFpga_Status_Success = 0; /** * The timeout expired before the FIFO operation could complete. */ -static const NiFpga_Status NiFpga_Status_FifoTimeout = -50400; +constexpr NiFpga_Status NiFpga_Status_FifoTimeout = -50400; /** * No transfer is in progress because the transfer was aborted by the client. * The operation could not be completed as specified. */ -static const NiFpga_Status NiFpga_Status_TransferAborted = -50405; +constexpr NiFpga_Status NiFpga_Status_TransferAborted = -50405; /** * A memory allocation failed. Try again after rebooting. */ -static const NiFpga_Status NiFpga_Status_MemoryFull = -52000; +constexpr NiFpga_Status NiFpga_Status_MemoryFull = -52000; /** * An unexpected software error occurred. */ -static const NiFpga_Status NiFpga_Status_SoftwareFault = -52003; +constexpr NiFpga_Status NiFpga_Status_SoftwareFault = -52003; /** * A parameter to a function was not valid. This could be a NULL pointer, a bad * value, etc. */ -static const NiFpga_Status NiFpga_Status_InvalidParameter = -52005; +constexpr NiFpga_Status NiFpga_Status_InvalidParameter = -52005; /** * A required resource was not found. The NiFpga.* library, the RIO resource, or * some other resource may be missing. */ -static const NiFpga_Status NiFpga_Status_ResourceNotFound = -52006; +constexpr NiFpga_Status NiFpga_Status_ResourceNotFound = -52006; /** * A required resource was not properly initialized. This could occur if * NiFpga_Initialize was not called or a required NiFpga_IrqContext was not * reserved. */ -static const NiFpga_Status NiFpga_Status_ResourceNotInitialized = -52010; +constexpr NiFpga_Status NiFpga_Status_ResourceNotInitialized = -52010; /** * A hardware failure has occurred. The operation could not be completed as * specified. */ -static const NiFpga_Status NiFpga_Status_HardwareFault = -52018; +constexpr NiFpga_Status NiFpga_Status_HardwareFault = -52018; /** * The FPGA is already running. */ -static const NiFpga_Status NiFpga_Status_FpgaAlreadyRunning = -61003; +constexpr NiFpga_Status NiFpga_Status_FpgaAlreadyRunning = -61003; /** * An error occurred downloading the VI to the FPGA device. Verify that * the target is connected and powered and that the resource of the target * is properly configured. */ -static const NiFpga_Status NiFpga_Status_DownloadError = -61018; +constexpr NiFpga_Status NiFpga_Status_DownloadError = -61018; /** * The bitfile was not compiled for the specified resource's device type. */ -static const NiFpga_Status NiFpga_Status_DeviceTypeMismatch = -61024; +constexpr NiFpga_Status NiFpga_Status_DeviceTypeMismatch = -61024; /** * An error was detected in the communication between the host computer and the * FPGA target. */ -static const NiFpga_Status NiFpga_Status_CommunicationTimeout = -61046; +constexpr NiFpga_Status NiFpga_Status_CommunicationTimeout = -61046; /** * The timeout expired before any of the IRQs were asserted. */ -static const NiFpga_Status NiFpga_Status_IrqTimeout = -61060; +constexpr NiFpga_Status NiFpga_Status_IrqTimeout = -61060; /** * The specified bitfile is invalid or corrupt. */ -static const NiFpga_Status NiFpga_Status_CorruptBitfile = -61070; +constexpr NiFpga_Status NiFpga_Status_CorruptBitfile = -61070; /** * The requested FIFO depth is invalid. It is either 0 or an amount not * supported by the hardware. */ -static const NiFpga_Status NiFpga_Status_BadDepth = -61072; +constexpr NiFpga_Status NiFpga_Status_BadDepth = -61072; /** * The number of FIFO elements is invalid. Either the number is greater than the * depth of the host memory DMA FIFO, or more elements were requested for * release than had been acquired. */ -static const NiFpga_Status NiFpga_Status_BadReadWriteCount = -61073; +constexpr NiFpga_Status NiFpga_Status_BadReadWriteCount = -61073; /** * A hardware clocking error occurred. A derived clock lost lock with its base @@ -218,62 +218,62 @@ static const NiFpga_Status NiFpga_Status_BadReadWriteCount = -61073; * generated from free-running, on-board sources, please contact National * Instruments technical support at ni.com/support. */ -static const NiFpga_Status NiFpga_Status_ClockLostLock = -61083; +constexpr NiFpga_Status NiFpga_Status_ClockLostLock = -61083; /** * The operation could not be performed because the FPGA is busy. Stop all * activities on the FPGA before requesting this operation. If the target is in * Scan Interface programming mode, put it in FPGA Interface programming mode. */ -static const NiFpga_Status NiFpga_Status_FpgaBusy = -61141; +constexpr NiFpga_Status NiFpga_Status_FpgaBusy = -61141; /** * The operation could not be performed because the FPGA is busy operating in * FPGA Interface C API mode. Stop all activities on the FPGA before requesting * this operation. */ -static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterfaceCApi = -61200; +constexpr NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterfaceCApi = -61200; /** * The chassis is in Scan Interface programming mode. In order to run FPGA VIs, * you must go to the chassis properties page, select FPGA programming mode, and * deploy settings. */ -static const NiFpga_Status NiFpga_Status_FpgaBusyScanInterface = -61201; +constexpr NiFpga_Status NiFpga_Status_FpgaBusyScanInterface = -61201; /** * The operation could not be performed because the FPGA is busy operating in * FPGA Interface mode. Stop all activities on the FPGA before requesting this * operation. */ -static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterface = -61202; +constexpr NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterface = -61202; /** * The operation could not be performed because the FPGA is busy operating in * Interactive mode. Stop all activities on the FPGA before requesting this * operation. */ -static const NiFpga_Status NiFpga_Status_FpgaBusyInteractive = -61203; +constexpr NiFpga_Status NiFpga_Status_FpgaBusyInteractive = -61203; /** * The operation could not be performed because the FPGA is busy operating in * Emulation mode. Stop all activities on the FPGA before requesting this * operation. */ -static const NiFpga_Status NiFpga_Status_FpgaBusyEmulation = -61204; +constexpr NiFpga_Status NiFpga_Status_FpgaBusyEmulation = -61204; /** * LabVIEW FPGA does not support the Reset method for bitfiles that allow * removal of implicit enable signals in single-cycle Timed Loops. */ -static const NiFpga_Status NiFpga_Status_ResetCalledWithImplicitEnableRemoval = +constexpr NiFpga_Status NiFpga_Status_ResetCalledWithImplicitEnableRemoval = -61211; /** * LabVIEW FPGA does not support the Abort method for bitfiles that allow * removal of implicit enable signals in single-cycle Timed Loops. */ -static const NiFpga_Status NiFpga_Status_AbortCalledWithImplicitEnableRemoval = +constexpr NiFpga_Status NiFpga_Status_AbortCalledWithImplicitEnableRemoval = -61212; /** @@ -282,7 +282,7 @@ static const NiFpga_Status NiFpga_Status_AbortCalledWithImplicitEnableRemoval = * Pass the NiFpga_CloseAttribute_NoResetIfLastSession attribute to NiFpga_Close * instead of 0. */ -static const NiFpga_Status +constexpr NiFpga_Status NiFpga_Status_CloseAndResetCalledWithImplicitEnableRemoval = -61213; /** @@ -290,14 +290,14 @@ static const NiFpga_Status * Timed Loops, LabVIEW FPGA does not support this method prior to running the * bitfile. */ -static const NiFpga_Status NiFpga_Status_ImplicitEnableRemovalButNotYetRun = +constexpr NiFpga_Status NiFpga_Status_ImplicitEnableRemovalButNotYetRun = -61214; /** * Bitfiles that allow removal of implicit enable signals in single-cycle Timed * Loops can run only once. Download the bitfile again before re-running the VI. */ -static const NiFpga_Status +constexpr NiFpga_Status NiFpga_Status_RunAfterStoppedCalledWithImplicitEnableRemoval = -61215; /** @@ -306,8 +306,7 @@ static const NiFpga_Status * protocol. If you are generating your clocks internally, please contact * National Instruments Technical Support. */ -static const NiFpga_Status NiFpga_Status_GatedClockHandshakingViolation = - -61216; +constexpr NiFpga_Status NiFpga_Status_GatedClockHandshakingViolation = -61216; /** * The number of elements requested must be less than or equal to the number of @@ -315,7 +314,7 @@ static const NiFpga_Status NiFpga_Status_GatedClockHandshakingViolation = * fewer unacquired elements left in the FIFO than are being requested. Release * some acquired elements before acquiring more elements. */ -static const NiFpga_Status NiFpga_Status_ElementsNotPermissibleToBeAcquired = +constexpr NiFpga_Status NiFpga_Status_ElementsNotPermissibleToBeAcquired = -61219; /** @@ -323,12 +322,12 @@ static const NiFpga_Status NiFpga_Status_ElementsNotPermissibleToBeAcquired = * discovery mode. Wait for configuration or discovery to complete and retry * your operation. */ -static const NiFpga_Status NiFpga_Status_FpgaBusyConfiguration = -61252; +constexpr NiFpga_Status NiFpga_Status_FpgaBusyConfiguration = -61252; /** * An unexpected internal error occurred. */ -static const NiFpga_Status NiFpga_Status_InternalError = -61499; +constexpr NiFpga_Status NiFpga_Status_InternalError = -61499; /** * The NI-RIO driver was unable to allocate memory for a FIFO. This can happen @@ -337,52 +336,52 @@ static const NiFpga_Status NiFpga_Status_InternalError = -61499; * to reconfigure the controller with a greater maximum FIFO depth. For more * information, refer to the NI KnowledgeBase article 65OF2ERQ. */ -static const NiFpga_Status NiFpga_Status_TotalDmaFifoDepthExceeded = -63003; +constexpr NiFpga_Status NiFpga_Status_TotalDmaFifoDepthExceeded = -63003; /** * Access to the remote system was denied. Use MAX to check the Remote Device * Access settings under Software>>NI-RIO>>NI-RIO Settings on the remote system. */ -static const NiFpga_Status NiFpga_Status_AccessDenied = -63033; +constexpr NiFpga_Status NiFpga_Status_AccessDenied = -63033; /** * The NI-RIO software on the host is not compatible with the software on the * target. Upgrade the NI-RIO software on the host in order to connect to this * target. */ -static const NiFpga_Status NiFpga_Status_HostVersionMismatch = -63038; +constexpr NiFpga_Status NiFpga_Status_HostVersionMismatch = -63038; /** * A connection could not be established to the specified remote device. Ensure * that the device is on and accessible over the network, that NI-RIO software * is installed, and that the RIO server is running and properly configured. */ -static const NiFpga_Status NiFpga_Status_RpcConnectionError = -63040; +constexpr NiFpga_Status NiFpga_Status_RpcConnectionError = -63040; /** * The RPC session is invalid. The target may have reset or been rebooted. Check * the network connection and retry the operation. */ -static const NiFpga_Status NiFpga_Status_RpcSessionError = -63043; +constexpr NiFpga_Status NiFpga_Status_RpcSessionError = -63043; /** * The operation could not complete because another session is accessing the * FIFO. Close the other session and retry. */ -static const NiFpga_Status NiFpga_Status_FifoReserved = -63082; +constexpr NiFpga_Status NiFpga_Status_FifoReserved = -63082; /** * A Configure FIFO, Stop FIFO, Read FIFO, or Write FIFO function was called * while the host had acquired elements of the FIFO. Release all acquired * elements before configuring, stopping, reading, or writing. */ -static const NiFpga_Status NiFpga_Status_FifoElementsCurrentlyAcquired = -63083; +constexpr NiFpga_Status NiFpga_Status_FifoElementsCurrentlyAcquired = -63083; /** * A function was called using a misaligned address. The address must be a * multiple of the size of the datatype. */ -static const NiFpga_Status NiFpga_Status_MisalignedAccess = -63084; +constexpr NiFpga_Status NiFpga_Status_MisalignedAccess = -63084; /** * The FPGA Read/Write Control Function is accessing a control or indicator @@ -390,7 +389,7 @@ static const NiFpga_Status NiFpga_Status_MisalignedAccess = -63084; * Refer to the hardware documentation for the limitations on data types for * this target. */ -static const NiFpga_Status NiFpga_Status_ControlOrIndicatorTooLarge = -63085; +constexpr NiFpga_Status NiFpga_Status_ControlOrIndicatorTooLarge = -63085; /** * A valid .lvbitx bitfile is required. If you are using a valid .lvbitx @@ -398,14 +397,14 @@ static const NiFpga_Status NiFpga_Status_ControlOrIndicatorTooLarge = -63085; * Determine which version of LabVIEW was used to make the bitfile, update your * software to that version or later, and try again. */ -static const NiFpga_Status NiFpga_Status_BitfileReadError = -63101; +constexpr NiFpga_Status NiFpga_Status_BitfileReadError = -63101; /** * The specified signature does not match the signature of the bitfile. If the * bitfile has been recompiled, regenerate the C API and rebuild the * application. */ -static const NiFpga_Status NiFpga_Status_SignatureMismatch = -63106; +constexpr NiFpga_Status NiFpga_Status_SignatureMismatch = -63106; /** * The bitfile you are trying to use is incompatible with the version @@ -415,33 +414,33 @@ static const NiFpga_Status NiFpga_Status_SignatureMismatch = -63106; * with the same version of NI-RIO that is currently installed on the * target and/or host. */ -static const NiFpga_Status NiFpga_Status_IncompatibleBitfile = -63107; +constexpr NiFpga_Status NiFpga_Status_IncompatibleBitfile = -63107; /** * Either the supplied resource name is invalid as a RIO resource name, or the * device was not found. Use MAX to find the proper resource name for the * intended device. */ -static const NiFpga_Status NiFpga_Status_InvalidResourceName = -63192; +constexpr NiFpga_Status NiFpga_Status_InvalidResourceName = -63192; /** * The requested feature is not supported. */ -static const NiFpga_Status NiFpga_Status_FeatureNotSupported = -63193; +constexpr NiFpga_Status NiFpga_Status_FeatureNotSupported = -63193; /** * The NI-RIO software on the target system is not compatible with this * software. Upgrade the NI-RIO software on the target system. */ -static const NiFpga_Status NiFpga_Status_VersionMismatch = -63194; +constexpr NiFpga_Status NiFpga_Status_VersionMismatch = -63194; /** * The session is invalid or has been closed. */ -static const NiFpga_Status NiFpga_Status_InvalidSession = -63195; +constexpr NiFpga_Status NiFpga_Status_InvalidSession = -63195; /** * The maximum number of open FPGA sessions has been reached. Close some open * sessions. */ -static const NiFpga_Status NiFpga_Status_OutOfHandles = -63198; +constexpr NiFpga_Status NiFpga_Status_OutOfHandles = -63198; diff --git a/hal/src/main/native/sim/HALInitializer.h b/hal/src/main/native/sim/HALInitializer.h index cace24006c..54e32499fd 100644 --- a/hal/src/main/native/sim/HALInitializer.h +++ b/hal/src/main/native/sim/HALInitializer.h @@ -6,11 +6,10 @@ #include -namespace hal { -namespace init { +namespace hal::init { extern std::atomic_bool HAL_IsInitialized; extern void RunInitialize(); -static inline void CheckInit() { +inline void CheckInit() { if (HAL_IsInitialized.load(std::memory_order_relaxed)) { return; } @@ -74,5 +73,4 @@ extern void InitializeSolenoid(); extern void InitializeSPI(); extern void InitializeThreads(); -} // namespace init -} // namespace hal +} // namespace hal::init diff --git a/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp b/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp index 21b0375254..d9fbe01389 100644 --- a/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp +++ b/hal/src/test/native/cpp/mockdata/AnalogInDataTests.cpp @@ -73,5 +73,6 @@ TEST(AnalogInSimTests, TestAnalogInInitialization) { EXPECT_TRUE(HAL_kInvalidHandle != analogInHandle); EXPECT_EQ(0, status); EXPECT_STREQ("Initialized", gTestAnalogInCallbackName.c_str()); + HALSIM_CancelAnalogInInitializedCallback(INDEX_TO_TEST, callbackId); } } // namespace hal diff --git a/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp b/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp index 482f842e14..16e1d9d957 100644 --- a/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp +++ b/hal/src/test/native/cpp/mockdata/AnalogOutDataTests.cpp @@ -73,5 +73,6 @@ TEST(AnalogOutSimTests, TestAnalogOutInitialization) { EXPECT_TRUE(HAL_kInvalidHandle != analogOutHandle); EXPECT_EQ(0, status); EXPECT_STREQ("Initialized", gTestAnalogOutCallbackName.c_str()); + HALSIM_CancelAnalogOutInitializedCallback(INDEX_TO_TEST, callbackId); } } // namespace hal diff --git a/hal/src/test/native/cpp/mockdata/DIODataTests.cpp b/hal/src/test/native/cpp/mockdata/DIODataTests.cpp index fb4b1bcd40..d584b45ec0 100644 --- a/hal/src/test/native/cpp/mockdata/DIODataTests.cpp +++ b/hal/src/test/native/cpp/mockdata/DIODataTests.cpp @@ -73,6 +73,7 @@ TEST(DigitalIoSimTests, TestDigitalIoInitialization) { EXPECT_TRUE(HAL_kInvalidHandle != digitalIoHandle); EXPECT_EQ(0, status); EXPECT_STREQ("Initialized", gTestDigitalIoCallbackName.c_str()); + HALSIM_CancelDIOInitializedCallback(INDEX_TO_TEST, callbackId); } } // namespace hal diff --git a/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp b/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp index 0767e0faf4..fb717971ac 100644 --- a/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp +++ b/hal/src/test/native/cpp/mockdata/PWMDataTests.cpp @@ -71,5 +71,6 @@ TEST(PWMSimTests, TestPwmInitialization) { EXPECT_TRUE(HAL_kInvalidHandle != pwmHandle); EXPECT_EQ(0, status); EXPECT_STREQ("Initialized", gTestPwmCallbackName.c_str()); + HALSIM_CancelPWMInitializedCallback(INDEX_TO_TEST, callbackId); } } // namespace hal diff --git a/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp b/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp index 8d4464227c..6e5004667d 100644 --- a/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp +++ b/hal/src/test/native/cpp/mockdata/RelayDataTests.cpp @@ -71,6 +71,7 @@ TEST(RelaySimTests, TestRelayInitialization) { EXPECT_TRUE(HAL_kInvalidHandle != pdpHandle); EXPECT_EQ(0, status); EXPECT_STREQ("InitializedForward", gTestRelayCallbackName.c_str()); + HALSIM_CancelRelayInitializedForwardCallback(INDEX_TO_TEST, callbackId); } } // namespace hal diff --git a/ntcore/src/main/native/cpp/Dispatcher.cpp b/ntcore/src/main/native/cpp/Dispatcher.cpp index 484a6063ec..ce6df31e59 100644 --- a/ntcore/src/main/native/cpp/Dispatcher.cpp +++ b/ntcore/src/main/native/cpp/Dispatcher.cpp @@ -448,10 +448,10 @@ void DispatcherBase::ServerThreadMain() { using namespace std::placeholders; auto conn = std::make_shared( ++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(conn))); { std::scoped_lock lock(m_user_mutex); @@ -507,10 +507,10 @@ void DispatcherBase::ClientThreadMain() { using namespace std::placeholders; auto conn = std::make_shared( ++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(conn))); m_connections.resize(0); // disconnect any current m_connections.emplace_back(conn); diff --git a/ntcore/src/main/native/cpp/InstanceImpl.cpp b/ntcore/src/main/native/cpp/InstanceImpl.cpp index c39ba0abe1..c0230b74d9 100644 --- a/ntcore/src/main/native/cpp/InstanceImpl.cpp +++ b/ntcore/src/main/native/cpp/InstanceImpl.cpp @@ -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), diff --git a/ntcore/src/main/native/cpp/NetworkConnection.cpp b/ntcore/src/main/native/cpp/NetworkConnection.cpp index 38a909e9ef..85957e2318 100644 --- a/ntcore/src/main/native/cpp/NetworkConnection.cpp +++ b/ntcore/src/main/native/cpp/NetworkConnection.cpp @@ -376,4 +376,4 @@ void NetworkConnection::PostOutgoing(bool keep_alive) { m_pending_update.resize(0); } m_last_post = now; -} +} // NOLINT diff --git a/ntcore/src/main/native/cpp/NetworkConnection.h b/ntcore/src/main/native/cpp/NetworkConnection.h index 3e2b8111b2..c7c659993e 100644 --- a/ntcore/src/main/native/cpp/NetworkConnection.h +++ b/ntcore/src/main/native/cpp/NetworkConnection.h @@ -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 msg) override; + void QueueOutgoing(std::shared_ptr 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); diff --git a/ntcore/src/main/native/cpp/ntcore_c.cpp b/ntcore/src/main/native/cpp/ntcore_c.cpp index 03f609035a..07b5bc4889 100644 --- a/ntcore/src/main/native/cpp/ntcore_c.cpp +++ b/ntcore/src/main/native/cpp/ntcore_c.cpp @@ -19,7 +19,7 @@ using namespace nt; static void ConvertToC(wpi::StringRef in, char** out) { *out = static_cast(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( - 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(wpi::safe_malloc(sizeof(NT_Value))); ConvertToC(*values_v[i], values[i]); diff --git a/simulation/frc_gazebo_plugins/src/limit_switch/headers/external_limit_switch.h b/simulation/frc_gazebo_plugins/src/limit_switch/headers/external_limit_switch.h index 51f2992f72..8a39f61101 100644 --- a/simulation/frc_gazebo_plugins/src/limit_switch/headers/external_limit_switch.h +++ b/simulation/frc_gazebo_plugins/src/limit_switch/headers/external_limit_switch.h @@ -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; diff --git a/simulation/frc_gazebo_plugins/src/limit_switch/headers/internal_limit_switch.h b/simulation/frc_gazebo_plugins/src/limit_switch/headers/internal_limit_switch.h index 94c84bc53b..11159c706d 100644 --- a/simulation/frc_gazebo_plugins/src/limit_switch/headers/internal_limit_switch.h +++ b/simulation/frc_gazebo_plugins/src/limit_switch/headers/internal_limit_switch.h @@ -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; diff --git a/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp b/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp index 18e658c0d7..1425ac082d 100644 --- a/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp +++ b/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp @@ -7,7 +7,7 @@ class DSCommPacketTest : public ::testing::Test { public: - DSCommPacketTest() {} + DSCommPacketTest() = default; void SendJoysticks() { commPacket.SendJoysticks(); } diff --git a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp index a3559ac49e..e52558bce7 100644 --- a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp @@ -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(payload->Data); // clear it from the other joysticks diff --git a/simulation/halsim_ws_core/src/main/native/include/WSHalProviders.h b/simulation/halsim_ws_core/src/main/native/include/WSHalProviders.h index 126be24571..619b0b5513 100644 --- a/simulation/halsim_ws_core/src/main/native/include/WSHalProviders.h +++ b/simulation/halsim_ws_core/src/main/native/include/WSHalProviders.h @@ -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 { diff --git a/simulation/halsim_ws_core/src/main/native/include/WSProvider_AddressableLED.h b/simulation/halsim_ws_core/src/main/native/include/WSProvider_AddressableLED.h index 48e6e9fe62..3970774214 100644 --- a/simulation/halsim_ws_core/src/main/native/include/WSProvider_AddressableLED.h +++ b/simulation/halsim_ws_core/src/main/native/include/WSProvider_AddressableLED.h @@ -12,7 +12,7 @@ class HALSimWSProviderAddressableLED : public HALSimWSHalChanProvider { static void Initialize(WSRegisterFunc webRegisterFunc); using HALSimWSHalChanProvider::HALSimWSHalChanProvider; - ~HALSimWSProviderAddressableLED(); + ~HALSimWSProviderAddressableLED() override; protected: void RegisterCallbacks() override; diff --git a/simulation/halsim_ws_core/src/main/native/include/WSProvider_Analog.h b/simulation/halsim_ws_core/src/main/native/include/WSProvider_Analog.h index a2f07d1f00..ec5771e961 100644 --- a/simulation/halsim_ws_core/src/main/native/include/WSProvider_Analog.h +++ b/simulation/halsim_ws_core/src/main/native/include/WSProvider_Analog.h @@ -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: diff --git a/simulation/halsim_ws_core/src/main/native/include/WSProvider_PCM.h b/simulation/halsim_ws_core/src/main/native/include/WSProvider_PCM.h index 92585ad42c..d12d6df20f 100644 --- a/simulation/halsim_ws_core/src/main/native/include/WSProvider_PCM.h +++ b/simulation/halsim_ws_core/src/main/native/include/WSProvider_PCM.h @@ -14,7 +14,7 @@ class HALSimWSProviderPCM : public HALSimWSHalChanProvider { static void Initialize(WSRegisterFunc webRegisterFunc); using HALSimWSHalChanProvider::HALSimWSHalChanProvider; - ~HALSimWSProviderPCM(); + ~HALSimWSProviderPCM() override; protected: void RegisterCallbacks() override; diff --git a/simulation/halsim_ws_core/src/main/native/include/WSProvider_Solenoid.h b/simulation/halsim_ws_core/src/main/native/include/WSProvider_Solenoid.h index e288345953..b6bc47a617 100644 --- a/simulation/halsim_ws_core/src/main/native/include/WSProvider_Solenoid.h +++ b/simulation/halsim_ws_core/src/main/native/include/WSProvider_Solenoid.h @@ -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; diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandTestBase.h b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandTestBase.h index 912936ba9f..07b1b97b5e 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandTestBase.h +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandTestBase.h @@ -65,7 +65,7 @@ class CommandTestBase : public ::testing::Test { .WillRepeatedly(::testing::Return(m_requirements)); } - MockCommand(const MockCommand& other) : Command{} {} + MockCommand(const MockCommand& other) : Command{other} {} void SetFinished(bool finished) { EXPECT_CALL(*this, IsFinished()) diff --git a/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h b/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h index 62e3059122..8a55a978f1 100644 --- a/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h +++ b/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h @@ -41,7 +41,7 @@ class BuiltInAccelerometer : public ErrorBase, * accelerometer will measure. Not all accelerometers support all * ranges. */ - void SetRange(Range range) override; + void SetRange(Range range) final; /** * @return The acceleration of the roboRIO along the X axis in g-forces diff --git a/wpilibc/src/main/native/include/frc/Counter.h b/wpilibc/src/main/native/include/frc/Counter.h index 47d877277d..dc0f4179e0 100644 --- a/wpilibc/src/main/native/include/frc/Counter.h +++ b/wpilibc/src/main/native/include/frc/Counter.h @@ -382,7 +382,7 @@ class Counter : public ErrorBase, * @param maxPeriod The maximum period where the counted device is considered * moving in seconds. */ - void SetMaxPeriod(double maxPeriod) override; + void SetMaxPeriod(double maxPeriod) final; /** * Select whether you want to continue updating the event timer output when diff --git a/wpilibc/src/test/native/cpp/simulation/DifferentialDriveSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/DifferentialDriveSimTest.cpp index 9965e76ead..d24249bfae 100644 --- a/wpilibc/src/test/native/cpp/simulation/DifferentialDriveSimTest.cpp +++ b/wpilibc/src/test/native/cpp/simulation/DifferentialDriveSimTest.cpp @@ -43,6 +43,7 @@ TEST(DifferentialDriveSim, Convergence) { auto trajectory = frc::TrajectoryGenerator::GenerateTrajectory( frc::Pose2d(), {}, frc::Pose2d(2_m, 2_m, 0_rad), config); + // NOLINTNEXTLINE for (double t = 0; t < trajectory.TotalTime().to(); t += 0.02) { auto state = trajectory.Sample(20_ms); auto ramseteOut = ramsete.Calculate(sim.GetPose(), state); diff --git a/wpimath/CMakeLists.txt b/wpimath/CMakeLists.txt index 2e373486cc..78bcf645ba 100644 --- a/wpimath/CMakeLists.txt +++ b/wpimath/CMakeLists.txt @@ -106,7 +106,7 @@ target_link_libraries(wpimath wpiutil) if (NOT USE_VCPKG_EIGEN) install(DIRECTORY src/main/native/eigeninclude/ DESTINATION "${include_dest}/wpimath") - target_include_directories(wpimath PUBLIC + target_include_directories(wpimath SYSTEM PUBLIC $ $) else() diff --git a/wpimath/src/main/native/cpp/jni/WPIMathJNI.cpp b/wpimath/src/main/native/cpp/jni/WPIMathJNI.cpp index 2c8f505b73..8c81a26d59 100644 --- a/wpimath/src/main/native/cpp/jni/WPIMathJNI.cpp +++ b/wpimath/src/main/native/cpp/jni/WPIMathJNI.cpp @@ -117,7 +117,7 @@ Java_edu_wpi_first_math_WPIMathJNI_pow Eigen::Map< Eigen::Matrix> - Amat{arrayBody, rows, rows}; + Amat{arrayBody, rows, rows}; // NOLINT Eigen::Matrix Apow = Amat.pow(exponent); @@ -146,7 +146,7 @@ Java_edu_wpi_first_math_WPIMathJNI_isStabilizable Eigen::Matrix> B{nativeB, states, inputs}; - bool isStabilizable = check_stabilizable(A, B); + bool isStabilizable = check_stabilizable(A, B); // NOLINT env->ReleaseDoubleArrayElements(aSrc, nativeA, 0); env->ReleaseDoubleArrayElements(bSrc, nativeB, 0); diff --git a/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp b/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp index 2bee2e8299..054799e950 100644 --- a/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp +++ b/wpimath/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp @@ -47,7 +47,7 @@ ChassisSpeeds MecanumDriveKinematics::ToChassisSpeeds( Eigen::Vector3d chassisSpeedsVector = m_forwardKinematics.solve(wheelSpeedsMatrix); - return {units::meters_per_second_t{chassisSpeedsVector(0)}, + return {units::meters_per_second_t{chassisSpeedsVector(0)}, // NOLINT units::meters_per_second_t{chassisSpeedsVector(1)}, units::radians_per_second_t{chassisSpeedsVector(2)}}; } diff --git a/wpimath/src/main/native/include/frc/controller/LinearPlantInversionFeedforward.h b/wpimath/src/main/native/include/frc/controller/LinearPlantInversionFeedforward.h index 20e1c9c230..03ddb4d87b 100644 --- a/wpimath/src/main/native/include/frc/controller/LinearPlantInversionFeedforward.h +++ b/wpimath/src/main/native/include/frc/controller/LinearPlantInversionFeedforward.h @@ -121,7 +121,7 @@ class LinearPlantInversionFeedforward { */ Eigen::Matrix Calculate( const Eigen::Matrix& nextR) { - return Calculate(m_r, nextR); + return Calculate(m_r, nextR); // NOLINT } /** diff --git a/wpiutil/src/main/native/cpp/PortForwarder.cpp b/wpiutil/src/main/native/cpp/PortForwarder.cpp index f385f26c4a..d2b80b14a9 100644 --- a/wpiutil/src/main/native/cpp/PortForwarder.cpp +++ b/wpiutil/src/main/native/cpp/PortForwarder.cpp @@ -33,6 +33,7 @@ static void CopyStream(uv::Stream& in, std::weak_ptr outWeak) { buf2.len = len; auto out = outWeak.lock(); if (!out) { + buf2.Deallocate(); in.Close(); return; } diff --git a/wpiutil/src/main/native/include/wpi/SocketError.h b/wpiutil/src/main/native/include/wpi/SocketError.h index e603de829e..b893ac6a6f 100644 --- a/wpiutil/src/main/native/include/wpi/SocketError.h +++ b/wpiutil/src/main/native/include/wpi/SocketError.h @@ -13,7 +13,7 @@ int SocketErrno(); std::string SocketStrerror(int code); -static inline std::string SocketStrerror() { +inline std::string SocketStrerror() { return SocketStrerror(SocketErrno()); } diff --git a/wpiutil/src/main/native/include/wpi/TCPStream.h b/wpiutil/src/main/native/include/wpi/TCPStream.h index 76cfe3aee9..5b5f6405d9 100644 --- a/wpiutil/src/main/native/include/wpi/TCPStream.h +++ b/wpiutil/src/main/native/include/wpi/TCPStream.h @@ -48,7 +48,7 @@ class TCPStream : public NetworkStream { size_t send(const char* buffer, size_t len, Error* err) override; size_t receive(char* buffer, size_t len, Error* err, int timeout = 0) override; - void close() override; + void close() final; StringRef getPeerIP() const override; int getPeerPort() const override; diff --git a/wpiutil/src/main/native/include/wpi/WebSocket.h b/wpiutil/src/main/native/include/wpi/WebSocket.h index 156d530846..54dedb145f 100644 --- a/wpiutil/src/main/native/include/wpi/WebSocket.h +++ b/wpiutil/src/main/native/include/wpi/WebSocket.h @@ -76,7 +76,7 @@ class WebSocket : public std::enable_shared_from_this { ClientOptions() : handshakeTimeout{(uv::Timer::Time::max)()} {} /** Timeout for the handshake request. */ - uv::Timer::Time handshakeTimeout; + uv::Timer::Time handshakeTimeout; // NOLINT /** Additional headers to include in handshake. */ ArrayRef> extraHeaders; diff --git a/wpiutil/src/main/native/include/wpi/jni_util.h b/wpiutil/src/main/native/include/wpi/jni_util.h index 1a493131be..df3075c390 100644 --- a/wpiutil/src/main/native/include/wpi/jni_util.h +++ b/wpiutil/src/main/native/include/wpi/jni_util.h @@ -23,11 +23,8 @@ #include "wpi/mutex.h" #include "wpi/raw_ostream.h" -/** WPILib C++ utilities (wpiutil) namespace */ -namespace wpi { - /** Java Native Interface (JNI) utility functions */ -namespace java { +namespace wpi::java { // Gets a Java stack trace. Also provides the last function // in the stack trace not starting with excludeFuncPrefix (useful for e.g. @@ -89,7 +86,7 @@ class JGlobal { explicit operator bool() const { return m_cls; } - operator T() const { return m_cls; } + operator T() const { return m_cls; } // NOLINT protected: T m_cls = nullptr; @@ -117,7 +114,7 @@ class JLocal { m_env->DeleteLocalRef(m_obj); } } - operator T() { return m_obj; } + operator T() { return m_obj; } // NOLINT T obj() { return m_obj; } private: @@ -151,7 +148,7 @@ class JStringRef { m_str.pop_back(); } - operator StringRef() const { return m_str; } + operator StringRef() const { return m_str; } // NOLINT StringRef str() const { return m_str; } const char* c_str() const { return m_str.data(); } size_t size() const { return m_str.size(); } @@ -187,7 +184,7 @@ class JArrayRefBase : public JArrayRefInner, T> { public: explicit operator bool() const { return this->m_elements != nullptr; } - operator ArrayRef() const { return array(); } + operator ArrayRef() const { return array(); } // NOLINT ArrayRef array() const { if (!this->m_elements) { @@ -501,7 +498,7 @@ inline jobjectArray MakeJStringArray(JNIEnv* env, ArrayRef arr) { template class JCallbackThread : public SafeThread { public: - void Main(); + void Main() override; std::queue m_queue; jobject m_func = nullptr; @@ -710,7 +707,6 @@ struct JExceptionInit { JException* cls; }; -} // namespace java -} // namespace wpi +} // namespace wpi::java #endif // WPIUTIL_WPI_JNI_UTIL_H_ diff --git a/wpiutil/src/main/native/include/wpi/uv/Buffer.h b/wpiutil/src/main/native/include/wpi/uv/Buffer.h index 530ee79ca0..80ea168885 100644 --- a/wpiutil/src/main/native/include/wpi/uv/Buffer.h +++ b/wpiutil/src/main/native/include/wpi/uv/Buffer.h @@ -155,7 +155,7 @@ class SimpleBufferPool { private: SmallVector m_pool; - size_t m_size; + size_t m_size; // NOLINT }; } // namespace wpi::uv diff --git a/wpiutil/src/test/native/ManagedStaticTest.cpp b/wpiutil/src/test/native/ManagedStaticTest.cpp index b78705c27b..ab54499556 100644 --- a/wpiutil/src/test/native/ManagedStaticTest.cpp +++ b/wpiutil/src/test/native/ManagedStaticTest.cpp @@ -20,6 +20,7 @@ TEST(ManagedStaticTest, LazyDoesNotInitialize) { { refCount = 0; wpi::ManagedStatic managedStatic; + (void)managedStatic; ASSERT_EQ(refCount, 0); } ASSERT_EQ(refCount, 0); @@ -43,7 +44,7 @@ TEST(ManagedStaticTest, EagerInit) { { refCount = 0; StaticTestClass* test = new StaticTestClass{}; - ASSERT_EQ(refCount, 1); + ASSERT_EQ(refCount, 1); // NOLINT wpi::ManagedStatic managedStatic( test, [](void* val) { delete static_cast(val); }); ASSERT_EQ(refCount, 1); diff --git a/wpiutil/src/test/native/cpp/uv/UvBufferTest.cpp b/wpiutil/src/test/native/cpp/uv/UvBufferTest.cpp index f15ae9d2c7..89f08d026a 100644 --- a/wpiutil/src/test/native/cpp/uv/UvBufferTest.cpp +++ b/wpiutil/src/test/native/cpp/uv/UvBufferTest.cpp @@ -11,13 +11,13 @@ namespace wpi::uv { TEST(UvSimpleBufferPool, ConstructDefault) { SimpleBufferPool<> pool; auto buf1 = pool.Allocate(); - ASSERT_EQ(buf1.len, 4096u); + ASSERT_EQ(buf1.len, 4096u); // NOLINT } TEST(UvSimpleBufferPool, ConstructSize) { SimpleBufferPool<4> pool{8192}; auto buf1 = pool.Allocate(); - ASSERT_EQ(buf1.len, 8192u); + ASSERT_EQ(buf1.len, 8192u); // NOLINT } TEST(UvSimpleBufferPool, ReleaseReuse) {