Skip to content

src: add STRONG_BOOL to replace bool args - #65142

Closed
jasnell wants to merge 2 commits into
nodejs:mainfrom
jasnell:jasnell/just-say-no-to-bool-args
Closed

src: add STRONG_BOOL to replace bool args#65142
jasnell wants to merge 2 commits into
nodejs:mainfrom
jasnell:jasnell/just-say-no-to-bool-args

Conversation

@jasnell

@jasnell jasnell commented Aug 8, 2026

Copy link
Copy Markdown
Member

Adopts the concept of strong bool arguments. Gives us a way to avoid bool args...

e.g.

void foo(bool whatever) { /* ... */ }

foo(true);  // what does `true` mean here?
foo(false);   // what does `false` mean here?

changes to:

STRONG_BOOL(WHATEVER);

void foo(WHATEVER whatever) { /* ... */ }

foo(WHATEVER::YES);  // self-documenting
foo(WHATEVER::NO);  // self-documenting

jasnell added 2 commits August 8, 2026 09:26
Signed-off-by: James M Snell <jasnell@gmail.com>
Mostly a demonstration of how to use STRONG_BOOL.
The idea here is provide a workable alternative to
using bool arguments where the callsites would
otherwise be somehting like `foo(true)` (what does
setting `true` mean here!?) to `foo(Bar::YES)`
(more self-documenting and readable).

The pattern here is adopted from what we do in
workerd and it's been a good quality of life
improvement.

Signed-off-by: James M Snell <jasnell@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 8, 2026
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.32%. Comparing base (98fd6cb) to head (c2d0be3).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_util.cc 40.00% 3 Missing ⚠️
src/crypto/crypto_tls.cc 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #65142   +/-   ##
=======================================
  Coverage   90.32%   90.32%           
=======================================
  Files         759      759           
  Lines      248320   248329    +9     
  Branches    46868    46861    -7     
=======================================
+ Hits       224296   224307   +11     
+ Misses      15466    15464    -2     
  Partials     8558     8558           
Files with missing lines Coverage Δ
src/crypto/crypto_tls.h 85.71% <100.00%> (+3.36%) ⬆️
src/crypto/crypto_util.h 67.52% <100.00%> (+0.09%) ⬆️
src/util.h 91.05% <100.00%> (+0.07%) ⬆️
src/crypto/crypto_tls.cc 78.83% <93.75%> (+0.03%) ⬆️
src/crypto/crypto_util.cc 72.04% <40.00%> (+0.05%) ⬆️

... and 30 files with indirect coverage changes

🚀 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.

@jasnell jasnell closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants