rust-bitcoin / rust-bitcoincore-rpc

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

Found string literal in env functions #336

Open philipjonsen opened 2 months ago

philipjonsen commented 2 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 2 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?