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

Found string literal in env functions RS-W1015 Bugrisk: Major #2688

Open
philipjonsen opened this issue Sep 22, 2024 · 0 comments
Open

Found string literal in env functions RS-W1015 Bugrisk: Major #2688

philipjonsen opened this issue Sep 22, 2024 · 0 comments

Comments

@philipjonsen
Copy link

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);

Using env::var with a string literal : https://github.com/nitro/blob/master/arbitrator/prover/build.rs#L86-L86

Using env::var with a string literal https://github.com/nitro/blob/master/arbitrator/brotli/build.rs#L7-L7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant