Skip to content
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

tidy: use modernize-use-raw-string-literal #25110

Closed

Conversation

fanquake
Copy link
Member

Refactor and turn on modernize-raw-string-literal. See https://clang.llvm.org/extra/clang-tidy/checks/modernize-raw-string-literal.html. This is a bit noisy, but I think ultimately worth it.

The motivation is to replace barely-(human)-parseable code like:

HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
+ HelpExampleRpc("logging", "[\"all\"], [\"libevent\"]")

with more-readable code like:

HelpExampleCli("logging", R"("[\"all\"]" "[\"http\"]")")
+ HelpExampleRpc("logging", R"(["all"], ["libevent"])")

while keeping the same output. i.e:

Examples:
Examples:
> bitcoin-cli logging "[\"all\"]" "[\"http\"]"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "logging", "params": [["all"], ["libevent"]]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Note that we already sporadically use raw string literals in the code base.

@ajtowns
Copy link
Contributor

ajtowns commented May 11, 2022

Just my opinion, but using R"" for any cases where we'd otherwise have three backslashes in a row ("\\\"") makes sense, but where it's just escaping an individual backslash or quote, it doesn't seem that useful to me.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 12, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #25276 (doc: Fix typo in importdescriptors by KolbyML)
  • #25218 (refactor: introduce generic 'Result' classes and connect them to CreateTransaction and GetNewDestination by furszy)
  • #24162 (rpc: add require_checksum flag to deriveaddresses by kallewoof)
  • #24161 (rpc/doc: describe using combo(privkey) to get checksum and then list … by kallewoof)
  • #23319 (rpc: Return fee and prevout (utxos) to getrawtransaction by dougEfresh)
  • #22838 (descriptors: Be able to specify change and receiving in a single descriptor string by achow101)

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.

The motivation is to replace barely (human) parse-able code like:

HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"")

with code like:

HelpExampleCli("createrawtransaction", R"("[{\"txid\" : \"mytxid\",\"vout\":0}]" "{\"myaddress\":0.01}")")
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 6, 2022

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@fanquake fanquake closed this Aug 8, 2022
Copy link

@8498549767 8498549767 left a comment

Choose a reason for hiding this comment

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

Exlente

@bitcoin bitcoin locked and limited conversation to collaborators Jan 24, 2023
@fanquake fanquake deleted the modernize_use_raw_string_literal branch September 14, 2023 10:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants