rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.31k stars 1.53k forks source link

URIs should not be hardcoded #13428

Open maijun-sec opened 1 week ago

maijun-sec commented 1 week ago

What it does

Hard-coded URIs can lead to several disadvantages in software development:

Advantage

Drawbacks

No response

Example

use reqwest::blocking::get;
use reqwest::Error;

// Noncompliant
const API_URL: &str = "http://example.com/api";

fn fetch_api_data() -> Result<String, Error> {
    let response = get(API_URL)?;
    response.text()
}
maijun-sec commented 1 week ago

we can reference some rules from other static analysis tools for different languages: