rust-bitcoin / rust-bitcoincore-rpc

Rust RPC client library for the Bitcoin Core JSON-RPC API.
343 stars 256 forks source link

Found string literal in env functions #336

Closed philipjonsen closed 1 month ago

philipjonsen commented 7 months ago

DESCRIPTION:

Calls to the std::env functions that use string literals instead of a static strings can lead to bugs due to spelling errors.

Consider using a static string to refer to environment variables.

BAD PRACTICE:

std::env::var("RUST_BACKTRACE"); // elsewhere ... std::env::remove_var("RUST_BACKTRCAE"); // misspelled

RECOMMENDED:

static RUST_BACKTRACE: &str = "RUST_BACKTRACE"; std::env::var(RUST_BACKTRACE); std::env::remove_var(RUST_BACKTRACE);

rust-bitcoincore-rpc/blob/master/integration_test/src/main.rs#L112-L119

apoelstra commented 7 months ago

I also noticed that almost every non-symbol string in this codebase could be spelled wrong. Maybe we should use cpp to substitute every single string for one that has extra "s?

mubarak23 commented 1 month ago

essentially every non-symbol string need to be check and confirm to follow the recommended pattern.

apoelstra commented 1 month ago

Blocked both of you.

apoelstra commented 1 month ago

Unblocked the latter user -- he contacted me privately and convinced me he was not a LLM. (But the original poster does appear to be a bot.)

I'll let this issue die now.