Skip to content

refactor: Fix clang-tidy bugprone-empty-catch check#6419

Merged
bthomee merged 11 commits intoXRPLF:developfrom
godexsoft:chore/clang-tidy-checks1
Mar 2, 2026
Merged

refactor: Fix clang-tidy bugprone-empty-catch check#6419
bthomee merged 11 commits intoXRPLF:developfrom
godexsoft:chore/clang-tidy-checks1

Conversation

@godexsoft
Copy link
Collaborator

@godexsoft godexsoft commented Feb 25, 2026

High Level Overview of Change

Fixes instances of bugprone-empty-catch of clang-tidy.

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

No impact.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 20.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.8%. Comparing base (1a7f824) to head (e2b26bc).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/libxrpl/protocol/STTx.cpp 0.0% 2 Missing ⚠️
src/xrpld/app/misc/detail/ValidatorSite.cpp 0.0% 2 Missing ⚠️
src/libxrpl/beast/insight/StatsDCollector.cpp 0.0% 1 Missing ⚠️
src/libxrpl/nodestore/backend/NuDBFactory.cpp 0.0% 1 Missing ⚠️
src/libxrpl/tx/transactors/XChainBridge.cpp 0.0% 1 Missing ⚠️
src/xrpld/app/ledger/detail/InboundLedgers.cpp 0.0% 1 Missing ⚠️
src/xrpld/app/ledger/detail/LedgerMaster.cpp 0.0% 1 Missing ⚠️
src/xrpld/app/main/GRPCServer.cpp 0.0% 1 Missing ⚠️
src/xrpld/overlay/detail/ConnectAttempt.cpp 0.0% 1 Missing ⚠️
src/xrpld/rpc/detail/RPCCall.cpp 0.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #6419     +/-   ##
=========================================
- Coverage     79.8%   79.8%   -0.0%     
=========================================
  Files          858     858             
  Lines        67757   67757             
  Branches      7562    7554      -8     
=========================================
- Hits         54081   54073      -8     
- Misses       13676   13684      +8     
Files with missing lines Coverage Δ
src/libxrpl/protocol/STAmount.cpp 88.3% <100.0%> (ø)
src/xrpld/app/ledger/detail/SkipListAcquire.cpp 95.9% <100.0%> (ø)
src/libxrpl/beast/insight/StatsDCollector.cpp 0.0% <0.0%> (ø)
src/libxrpl/nodestore/backend/NuDBFactory.cpp 64.3% <0.0%> (ø)
src/libxrpl/tx/transactors/XChainBridge.cpp 91.2% <0.0%> (ø)
src/xrpld/app/ledger/detail/InboundLedgers.cpp 36.4% <0.0%> (ø)
src/xrpld/app/ledger/detail/LedgerMaster.cpp 42.7% <0.0%> (ø)
src/xrpld/app/main/GRPCServer.cpp 42.2% <0.0%> (ø)
src/xrpld/overlay/detail/ConnectAttempt.cpp 0.0% <0.0%> (ø)
src/xrpld/rpc/detail/RPCCall.cpp 93.6% <0.0%> (ø)
... and 2 more

... and 3 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings February 27, 2026 16:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses clang-tidy's bugprone-empty-catch check by adding suppressions for intentional empty catch blocks and refactoring code to move return statements into catch blocks. The PR enables the check in .clang-tidy configuration and adds the related suppressions (NOLINT and NOLINTNEXTLINE) to the spell-checker dictionary.

Changes:

  • Enabled bugprone-empty-catch check in .clang-tidy configuration
  • Added NOLINT suppressions to 16 intentional empty catch blocks across production and test code
  • Refactored 5 functions to move return statements from after catch blocks into the catch blocks themselves
  • Added NOLINT and NOLINTNEXTLINE to cspell.config.yaml

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.clang-tidy Enabled bugprone-empty-catch check and moved it from disabled list to enabled list
cspell.config.yaml Added NOLINT and NOLINTNEXTLINE to dictionary for spell-checking
src/xrpld/rpc/detail/RPCCall.cpp Added NOLINT suppression for intentional empty catch in config file handling
src/xrpld/overlay/detail/ConnectAttempt.cpp Added NOLINT suppression for timer cancel error handling
src/xrpld/app/misc/detail/ValidatorSite.cpp Added NOLINT suppressions in 2 places for timer cancel error handling
src/xrpld/app/main/GRPCServer.cpp Added NOLINT suppression for endpoint parsing error handling
src/xrpld/app/ledger/detail/SkipListAcquire.cpp Added NOLINT suppression for data processing error handling
src/xrpld/app/ledger/detail/LedgerMaster.cpp Added NOLINT suppression for missing node error handling
src/xrpld/app/ledger/detail/InboundLedgers.cpp Added NOLINT suppression for node data error handling
src/libxrpl/nodestore/backend/NuDBFactory.cpp Added NOLINT suppression in destructor for close error handling
src/libxrpl/beast/insight/StatsDCollector.cpp Added NOLINT suppression for timer cancel error handling
src/tests/libxrpl/basics/scope.cpp Added NOLINT suppressions in 6 test cases for scope guard testing
src/test/jtx/impl/WSClient.cpp Added NOLINTNEXTLINE suppression for stream cancel error handling
src/test/jtx/impl/Oracle.cpp Moved return statement into catch block for validation function
src/test/jtx/impl/Env.cpp Moved return statements into catch blocks in 2 functions and changed exception type from std::exception const& to ...
src/test/core/SociDB_test.cpp Added NOLINT suppressions in setup and cleanup methods
src/test/app/Manifest_test.cpp Added NOLINT suppressions in setup and cleanup methods
src/libxrpl/tx/transactors/XChainBridge.cpp Moved return statement into existing catch(...) block
src/libxrpl/protocol/STTx.cpp Moved return statement into catch block and changed exception type from std::exception const& to ...
src/libxrpl/protocol/STAmount.cpp Moved return statement into catch block, changed exception type from std::exception const& to ..., and added blank line for readability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kuznetsss
Copy link
Collaborator

Probably, it is better to add a NOLINT comment instead of changing catch(some_exception) to catch(...) to not change the code behaviour. Other than that looks good.

@godexsoft
Copy link
Collaborator Author

Probably, it is better to add a NOLINT comment instead of changing catch(some_exception) to catch(...) to not change the code behaviour. Other than that looks good.

Copilot makes it sound very scary but in reality i think it's the same thing (yes technically it could change behaviour but i doubt the code throws anything that isn't derived from std::exception.
There are only a handful of places so perhaps we can ask @ximinez to take a look and decide. It's easy to add NOLINT if that's the conclusion.

@godexsoft godexsoft requested a review from ximinez February 27, 2026 16:54
Copy link
Collaborator

@ximinez ximinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the places that you converted to catch (...) certainly look to me like they were intended as a "catch everything", and only limited it to std::exception because that's what's supposed to be thrown.

Comment on lines 68 to 87
Manifest_test()
{
try
{
setupDatabaseDir(getDatabasePath());
}
catch (std::exception const&)
catch (std::exception const&) // NOLINT(bugprone-empty-catch)
{
}
}
~Manifest_test()
{
try
{
cleanupDatabaseDir(getDatabasePath());
}
catch (std::exception const&)
catch (std::exception const&) // NOLINT(bugprone-empty-catch)
{
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably beyond the scope of this PR, but this is an usual (though not unique) pattern. Usually everything meaningful is done in run() (or in the one(?) test that actually puts anything in that folder).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should review all our exception use in the codebase some day.

Copilot AI review requested due to automatic review settings March 2, 2026 15:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@godexsoft godexsoft added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Mar 2, 2026
Copy link
Collaborator

@kuznetsss kuznetsss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bthomee bthomee changed the title chore: Fix clang-tidy bugprone-empty-catch check refactor: Fix clang-tidy bugprone-empty-catch check Mar 2, 2026
@bthomee bthomee enabled auto-merge (squash) March 2, 2026 16:48
@bthomee bthomee merged commit afc660a into XRPLF:develop Mar 2, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants