refactor: add clang-tidy modernize-use-starts-ends-with
check
#30868
pull
romanz
wants to merge
1
commits into
bitcoin:master
from
romanz:starts-with
changing
4
files
+4 −3
-
romanz commented at 4:11 am on September 11, 2024: contributor
-
DrahtBot commented at 4:11 am on September 11, 2024: contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Code Coverage
For detailed information about the code coverage, see the test coverage report.
Reviews
See the guideline for information on the review process.
Type Reviewers ACK stickies-v, hebasto, jonatack, achow101 If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #30679 (fix: handle invalid
-rpcbind
port earlier by tdb3)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
- #30679 (fix: handle invalid
-
DrahtBot added the label RPC/REST/ZMQ on Sep 11, 2024
-
maflcko commented at 5:56 am on September 11, 2024: memberIf there is support for this change, it may be better to use and enable https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-starts-ends-with.html . Otherwise, follow-up pull requests may be created for each instance individually. Also, newly introduced code may re-introduce new instances.
-
DrahtBot added the label CI failed on Sep 11, 2024
-
maflcko commented at 9:03 pm on September 11, 2024: memberPlease squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits
-
romanz force-pushed on Sep 12, 2024
-
stickies-v commented at 1:06 pm on September 12, 2024: contributorCode LGTM eb43872b84bfc4d09fe38ce0cb74722f6f9842da. Commit message and PR title need updating, this is a
tidy
change now affecting multiple modules, not anhttp
change. -
romanz force-pushed on Sep 12, 2024
-
romanz renamed this:
http: Use 'starts_with' for matching URI prefix
tidy: Use 'starts_with' instead of substr/find
on Sep 12, 2024 -
maflcko removed the label RPC/REST/ZMQ on Sep 12, 2024
-
DrahtBot removed the label CI failed on Sep 13, 2024
-
jonatack commented at 4:05 pm on September 13, 2024: member
ACK 22bc9fdca314549bf204d3e3f577d7f014858f42
Maybe name this PR (and the commit, if you need to retouch):
tidy: add clang-tidy
modernize-use-starts-ends-with
check -
jonatack commented at 4:10 pm on September 13, 2024: member
The red CI is an unrelated timeout.
I’m still adapting to the new build system, but fwiw, locally it looks like no unit tests fail if I flip the changed conditionals to the opposite boolean. Functional tests do fail.
-
tidy: add clang-tidy `modernize-use-starts-ends-with` check fc7b507e9a
-
romanz force-pushed on Sep 14, 2024
-
romanz renamed this:
tidy: Use 'starts_with' instead of substr/find
tidy: add clang-tidy `modernize-use-starts-ends-with` check
on Sep 14, 2024 -
stickies-v approved
-
stickies-v commented at 11:06 am on September 16, 2024: contributorACK fc7b507e9a595a7bf91f4e0f42b4d842af8b93f3
-
DrahtBot requested review from jonatack on Sep 16, 2024
-
DrahtBot renamed this:
tidy: add clang-tidy `modernize-use-starts-ends-with` check
refactor: add clang-tidy `modernize-use-starts-ends-with` check
on Sep 16, 2024 -
DrahtBot added the label Refactoring on Sep 16, 2024
-
hebasto approved
-
hebasto commented at 11:17 am on September 16, 2024: memberACK fc7b507e9a595a7bf91f4e0f42b4d842af8b93f3, I have reviewed the code and it looks OK.
-
jonatack commented at 2:04 pm on September 16, 2024: memberre-ACK fc7b507e9a595a7bf91f4e0f42b4d842af8b93f3 only change since my previous ACK is the commit message
-
achow101 commented at 7:35 pm on September 16, 2024: memberACK fc7b507e9a595a7bf91f4e0f42b4d842af8b93f3
-
achow101 merged this on Sep 16, 2024
-
achow101 closed this on Sep 16, 2024
-
romanz deleted the branch on Sep 16, 2024
-
romanz commented at 7:51 pm on September 16, 2024: contributorMany thanks!
-
fanquake commented at 11:16 am on October 1, 2024: member
Seems like newer Clang 19 has improved this check, and throws out more (historical) instances to change. i.e:
0bitcoin/src/torcontrol.cpp:359:27: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 1 359 | if (0 == line.compare(0, 20, "net/listeners/socks=")) { 2 | ~~~~ ^~~~~~~~~~~~~~ ~ 3 | starts_with( ) 4bitcoin/src/torcontrol.cpp:370:38: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 5 370 | if (0 == portstr.compare(0, 10, "127.0.0.1:")) { 6 | ~~~~ ^~~~~~~~~~~~~~ ~ 7 | starts_with( ) 8bitcoin/src/core_read.cpp:42:25: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 9 42 | if (strName.compare(0, 3, "OP_") == 0) { // strName starts with "OP_" 10 | ^~~~~~~~~~~~~ ~~~~~~ 11 | starts_with( ) 12bitcoin/src/wallet/walletdb.cpp:1016:27: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 13 1016 | } else if (strKey.compare(0, 2, "rr") == 0) { 14 | ^~~~~~~~~~~~~ ~~~~~~ 15 | starts_with( ) 16<snip the rest>
-
TheCharlatan referenced this in commit 8bb47d4c2c on Nov 2, 2024
-
hebasto commented at 4:26 pm on November 17, 2024: member
Seems like newer Clang 19 has improved this check, and throws out more (historical) instances to change. i.e:
0bitcoin/src/torcontrol.cpp:359:27: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 1 359 | if (0 == line.compare(0, 20, "net/listeners/socks=")) { 2 | ~~~~ ^~~~~~~~~~~~~~ ~ 3 | starts_with( ) 4bitcoin/src/torcontrol.cpp:370:38: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 5 370 | if (0 == portstr.compare(0, 10, "127.0.0.1:")) { 6 | ~~~~ ^~~~~~~~~~~~~~ ~ 7 | starts_with( ) 8bitcoin/src/core_read.cpp:42:25: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 9 42 | if (strName.compare(0, 3, "OP_") == 0) { // strName starts with "OP_" 10 | ^~~~~~~~~~~~~ ~~~~~~ 11 | starts_with( ) 12bitcoin/src/wallet/walletdb.cpp:1016:27: error: use starts_with instead of compare() == 0 [modernize-use-starts-ends-with,-warnings-as-errors] 13 1016 | } else if (strKey.compare(0, 2, "rr") == 0) { 14 | ^~~~~~~~~~~~~ ~~~~~~ 15 | starts_with( ) 16<snip the rest>
Addressed in #31306.
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-26 12:12 UTC
More mirrored repositories can be found on mirror.b10c.me