Skip to content

Conversation

@bthomee
Copy link
Collaborator

@bthomee bthomee commented Feb 26, 2025

High Level Overview of Change

This change replaces all static_cast by safe_cast or unsafe_cast wherever possible.

Context of Change

The intention of the safe_cast and unsafe_cast functions is mainly for developers. It allows you to see at a glance if you have to worry about overflows and similar issues. They are also a great shortcut for casting enums. The functions are only for integral types for now, but they could be extended to cover other types in the future.

The change in this PR:

  1. Replaced all static_cast calls by safe_cast calls.
  2. Repeatedly compiled, and changed safe_cast to unsafe_cast or otherwise to static_cast if building failed.
  3. Added the safe_cast.h include if needed.

Type of Change

  • Refactor (non-breaking change that only restructures code)

@codecov
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 81.51261% with 44 lines in your changes missing coverage. Please review.

Project coverage is 78.2%. Comparing base (68ba202) to head (dea68dc).
Report is 30 commits behind head on bthomee/quality.

Files with missing lines Patch % Lines
src/libxrpl/json/json_reader.cpp 44.4% 10 Missing ⚠️
src/xrpld/overlay/detail/PeerImp.cpp 0.0% 7 Missing ⚠️
src/xrpld/app/misc/NetworkOPs.cpp 68.8% 5 Missing ⚠️
src/libxrpl/protocol/STAmount.cpp 83.3% 3 Missing ⚠️
include/xrpl/basics/CompressionAlgorithms.h 0.0% 2 Missing ⚠️
include/xrpl/protocol/AmountConversions.h 0.0% 2 Missing ⚠️
src/xrpld/overlay/Compression.h 0.0% 2 Missing ⚠️
include/xrpl/protocol/detail/token_errors.h 50.0% 1 Missing ⚠️
src/libxrpl/crypto/RFC1751.cpp 83.3% 1 Missing ⚠️
src/libxrpl/json/json_writer.cpp 83.3% 1 Missing ⚠️
... and 10 more
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##           bthomee/quality   #5319   +/-   ##
===============================================
  Coverage             78.2%   78.2%           
===============================================
  Files                  790     790           
  Lines                67725   67725           
  Branches              8175    8175           
===============================================
+ Hits                 52945   52947    +2     
+ Misses               14780   14778    -2     
Files with missing lines Coverage Δ
include/xrpl/basics/StringUtilities.h 100.0% <100.0%> (ø)
include/xrpl/basics/TaggedCache.h 87.2% <100.0%> (ø)
include/xrpl/basics/base_uint.h 96.8% <100.0%> (ø)
include/xrpl/basics/random.h 100.0% <100.0%> (ø)
include/xrpl/protocol/HashPrefix.h 100.0% <100.0%> (ø)
include/xrpl/protocol/MultiApiJson.h 100.0% <100.0%> (ø)
include/xrpl/protocol/Quality.h 98.6% <100.0%> (ø)
include/xrpl/protocol/STBase.h 94.1% <ø> (ø)
include/xrpl/protocol/Serializer.h 94.8% <100.0%> (ø)
include/xrpl/protocol/XRPAmount.h 98.9% <100.0%> (ø)
... and 68 more

... and 2 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bthomee
Copy link
Collaborator Author

bthomee commented May 27, 2025

We'll use automated tools to identify and, hopefully, fix these issues by running as pre-commit.

@bthomee bthomee closed this May 27, 2025
@bthomee bthomee deleted the bthomee/cast branch May 27, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants