-
Notifications
You must be signed in to change notification settings - Fork 37.8k
univalue: Remove confusing getBool method #26673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Drop UniValue::getBool method because it is easy to confuse with the UniValue::get_bool method, and could potentially cause bugs. Unlike get_bool, getBool doesn't ensure that the value is a boolean and returns false for all integer, string, array, and object values instead of throwing an exceptions. The getBool method is also redundant because it is an alias for isTrue. There were only 5 getBool() calls in the codebase, so this commit replaces them with isTrue() or get_bool() calls as appropriate. These changes were originally made by MarcoFalke in bitcoin#26213 but were dropped to limit the scope of that PR. Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
Concept ACK.
And 4 of them are in tests. |
ACK 293849a |
utACK 293849a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 293849a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 293849a, also verified that the removed getBool
method is not mentioned in any docs:
$ git grep getBool | wc -l
0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 293849a
First glance, seems that a good follow-up would be to minimize the isFalse
and isTrue
methods usage scope as well. Probably only SettingToString
and SettingToInt
requires them.
EDIT: NVM I see you reviewed it already! |
Actually, I forgot that one hehe. Thanks for the reminder! |
293849a univalue: Remove confusing getBool method (Ryan Ofsky) Pull request description: Drop `UniValue::getBool` method because it is easy to confuse with the `UniValue::get_bool` method, and could potentially cause bugs. Unlike `get_bool`, `getBool` doesn't ensure that the value is a boolean and returns false for all integer, string, array, and object values instead of throwing an exception. The `getBool` method is also redundant because it is an alias for `isTrue`. There were only 5 `getBool()` calls in the codebase, so this commit replaces them with `isTrue()` or `get_bool()` calls as appropriate. These changes were originally made by MarcoFalke in bitcoin#26213 but were dropped to limit the scope of that PR. ACKs for top commit: justinpickering: ACK bitcoin@293849a sipa: utACK 293849a w0xlt: ACK bitcoin@293849a hebasto: ACK 293849a, also verified that the removed `getBool` method is not mentioned in any docs: furszy: ACK 293849a Tree-SHA512: 9fbfe5e2083410f123b18703a0cc0161ecbbb4958f331c9ff808dcfcc6ad499b0e896abd16fb8ea200c53ba29878db9812ce141e59cc5e0fd174741b0bcb192d
Drop
UniValue::getBool
method because it is easy to confuse with theUniValue::get_bool
method, and could potentially cause bugs. Unlikeget_bool
,getBool
doesn't ensure that the value is a boolean and returns false for all integer, string, array, and object values instead of throwing an exception.The
getBool
method is also redundant because it is an alias forisTrue
. There were only 5getBool()
calls in the codebase, so this commit replaces them withisTrue()
orget_bool()
calls as appropriate.These changes were originally made by MarcoFalke in #26213 but were dropped to limit the scope of that PR.