Skip to content

Commit c00446c

Browse files
committed
clippy
1 parent 94a56bf commit c00446c

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

build.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ fn make_client() -> awc::Client {
3636

3737
/// Creates a file with inlined remote files included
3838
async fn download_deps(client: Rc<awc::Client>, filename: &str) {
39-
let path_in = format!("sqlpage/{}", filename);
39+
let path_in = format!("sqlpage/{filename}");
4040
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
4141
let path_out: PathBuf = out_dir.join(filename);
4242
// Generate outfile by reading infile and interpreting all comments
4343
// like "/* !include https://... */" as a request to include the contents of
4444
// the URL in the generated file.
45-
println!("cargo:rerun-if-changed={}", path_in);
45+
println!("cargo:rerun-if-changed={path_in}");
4646
let original = File::open(path_in).unwrap();
4747
process_input_file(&client, &path_out, original).await;
4848
std::fs::write(
@@ -68,7 +68,7 @@ async fn process_input_file(client: &awc::Client, path_out: &Path, original: Fil
6868
}
6969
outfile.write_all(b"\n").unwrap();
7070
} else {
71-
writeln!(outfile, "{}", line).unwrap();
71+
writeln!(outfile, "{line}").unwrap();
7272
}
7373
}
7474
outfile
@@ -119,10 +119,9 @@ async fn download_url_to_path(client: &awc::Client, url: &str, path: &Path) {
119119
let path = make_url_path(url);
120120
panic!(
121121
"We need to download external frontend dependencies to build the static frontend. \n\
122-
Could not download static asset after {} attempts. You can manually download the file with: \n\
122+
Could not download static asset after {max_attempts} attempts. You can manually download the file with: \n\
123123
curl {url:?} > {path:?} \n\
124-
{err}",
125-
max_attempts
124+
{err}"
126125
);
127126
}
128127
sleep(Duration::from_secs(1)).await;

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use sqlpage::{
88
async fn main() {
99
init_logging();
1010
if let Err(e) = start().await {
11-
log::error!("{:?}", e);
11+
log::error!("{e:?}");
1212
std::process::exit(1);
1313
}
1414
}
@@ -38,6 +38,6 @@ fn init_logging() {
3838
Err(dotenvy::Error::Io(e)) if e.kind() == std::io::ErrorKind::NotFound => log::debug!(
3939
"No .env file found, using only environment variables and configuration files"
4040
),
41-
Err(e) => log::error!("Error loading .env file: {}", e),
41+
Err(e) => log::error!("Error loading .env file: {e}"),
4242
}
4343
}

src/render.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ impl HeaderContext {
9292
) -> Self {
9393
let mut response = HttpResponseBuilder::new(StatusCode::OK);
9494
response.content_type("text/html; charset=utf-8");
95+
let tpl = &app_state.config.content_security_policy;
9596
request_context
9697
.content_security_policy
97-
.apply_to_response(&mut response);
98+
.apply_to_response(tpl, &mut response);
9899
Self {
99100
app_state,
100101
request_context,

src/webserver/http.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ async fn render_sql(
177177
actix_web::rt::spawn(async move {
178178
let request_context = RequestContext {
179179
is_embedded: req_param.get_variables.contains_key("_sqlpage_embed"),
180-
content_security_policy: ContentSecurityPolicy::new(
181-
app_state.config.content_security_policy.clone(),
182-
),
180+
content_security_policy: ContentSecurityPolicy::with_random_nonce(),
183181
};
184182
let mut conn = None;
185183
let database_entries_stream =

tests/index.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async fn test_concurrent_requests() {
9494
.map(|i| {
9595
let component = components[i % components.len()];
9696
req_path_with_app_data(
97-
format!("/tests/any_component.sql?component={}", component),
97+
format!("/tests/any_component.sql?component={component}"),
9898
app_data.clone(),
9999
)
100100
})
@@ -185,7 +185,7 @@ async fn test_files() {
185185
// skipping because the test does not support the database
186186
continue;
187187
}
188-
let req_str = format!("/{}?x=1", test_file_path_string);
188+
let req_str = format!("/{test_file_path_string}?x=1");
189189
let resp = req_path_with_app_data(&req_str, app_data.clone())
190190
.await
191191
.unwrap_or_else(|e| panic!("Failed to get response for {req_str}: {e}"));
@@ -966,16 +966,15 @@ pub fn test_config() -> AppConfig {
966966
let db_url = test_database_url();
967967
serde_json::from_str::<AppConfig>(&format!(
968968
r#"{{
969-
"database_url": "{}",
969+
"database_url": "{db_url}",
970970
"max_database_pool_connections": 1,
971971
"database_connection_retries": 3,
972972
"database_connection_acquire_timeout_seconds": 15,
973973
"allow_exec": true,
974974
"max_uploaded_file_size": 123456,
975975
"listen_on": "111.111.111.111:1",
976976
"system_root_ca_certificates" : false
977-
}}"#,
978-
db_url
977+
}}"#
979978
))
980979
.unwrap()
981980
}

0 commit comments

Comments
 (0)