Skip to content

Commit

Permalink
cargo clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 1, 2023
1 parent 222a608 commit 58a32df
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 42 deletions.
2 changes: 1 addition & 1 deletion fastn-core/src/apis/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub async fn edit(
Ok(config) => config,
Err(err) => return fastn_core::http::api_error(err.to_string()),
};
let mut req_config = fastn_core::RequestConfig::new(&config, &req);
let mut req_config = fastn_core::RequestConfig::new(&config, req);
req_config.current_document = Some(req_data.path.to_string());

match req_config.can_write(req_data.path.as_str()).await {
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/apis/edit_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn handle_view_source(
path: &str,
) -> fastn_core::Result<Vec<u8>> {
let config = fastn_core::Config::read(None, false).await?;
let mut req_config = fastn_core::RequestConfig::new(&config, &req);
let mut req_config = fastn_core::RequestConfig::new(&config, req);

let file_name = config.get_file_path_and_resolve(path).await?;
let file = req_config.get_file_and_package_by_id(path).await?;
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/apis/view_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn handle_view_source(
path: &str,
) -> fastn_core::Result<Vec<u8>> {
let config = fastn_core::Config::read(None, false).await?;
let mut req_config = fastn_core::RequestConfig::new(&config, &req);
let mut req_config = fastn_core::RequestConfig::new(&config, req);
let file_name = config.get_file_path_and_resolve(path).await?;
let file = req_config.get_file_and_package_by_id(path).await?;

Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ async fn handle_file_(
}

let req = fastn_core::http::Request::default();
let mut req_config = fastn_core::RequestConfig::new(&config, &req);
let mut req_config = fastn_core::RequestConfig::new(config, &req);
req_config.current_document = Some(document.get_id().to_string());

async fn f<'a>(
Expand Down
4 changes: 2 additions & 2 deletions fastn-core/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub async fn serve(
let path: camino::Utf8PathBuf = req.path().replacen('/', "", 1).parse()?;

Ok(if path.eq(&camino::Utf8PathBuf::new().join("FASTN.ftd")) {
serve_fastn_file(&config).await
serve_fastn_file(config).await
} else if path.eq(&camino::Utf8PathBuf::new().join("")) {
serve_file(&mut req_config, &path.join("/")).await
} else if let Some(cr_number) = fastn_core::cr::get_cr_path_from_url(path.as_str()) {
Expand Down Expand Up @@ -323,7 +323,7 @@ pub async fn serve(
// Already checked in the above method serve_file
tracing::info!("executing proxy: path: {}", &path);
let (package_name, url, mut conf) =
fastn_core::config::utils::get_clean_url(&config, path.as_str())?;
fastn_core::config::utils::get_clean_url(config, path.as_str())?;
let package_name = package_name.unwrap_or_else(|| config.package.name.to_string());

let host = if let Some(port) = url.port() {
Expand Down
8 changes: 4 additions & 4 deletions fastn-core/src/library/fastn_dot_ftd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn i18n_data(lib: &fastn_core::Library<'_>) -> String {

let current_document_last_modified_on =
fastn_core::utils::get_current_document_last_modified_on(
&lib.config.config,
lib.config.config,
lib.document_id.as_str(),
)
.await;
Expand Down Expand Up @@ -267,7 +267,7 @@ pub(crate) async fn get2022_(lib: &fastn_core::Library<'_>) -> String {
);

if let Ok(number_of_documents) = futures::executor::block_on(
fastn_core::utils::get_number_of_documents(&lib.config.config),
fastn_core::utils::get_number_of_documents(lib.config.config),
) {
fastn_base = format!(
indoc::indoc! {"
Expand Down Expand Up @@ -406,7 +406,7 @@ pub(crate) async fn get(lib: &fastn_core::Library<'_>) -> String {
}

if let Ok(number_of_documents) = futures::executor::block_on(
fastn_core::utils::get_number_of_documents(&lib.config.config),
fastn_core::utils::get_number_of_documents(lib.config.config),
) {
fastn_base = format!(
indoc::indoc! {"
Expand Down Expand Up @@ -435,7 +435,7 @@ pub(crate) async fn get(lib: &fastn_core::Library<'_>) -> String {

if let Some(last_modified_on) =
futures::executor::block_on(fastn_core::utils::get_current_document_last_modified_on(
&lib.config.config,
lib.config.config,
lib.document_id.as_str(),
))
{
Expand Down
42 changes: 21 additions & 21 deletions fastn-core/src/library2022/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,63 +243,63 @@ impl Library2022<'_, '_> {
"figma-cs-token-old" => {
processor::figma_tokens::process_figma_tokens_old(value, kind, doc)
}
"http" => processor::http::process(value, kind, doc, &self.config).await,
"http" => processor::http::process(value, kind, doc, self.config).await,
"tutor" => fastn_core::tutor::process(value, kind, doc).await,
"toc" => processor::toc::process(value, kind, doc),
"get-data" => processor::get_data::process(value, kind, doc, &self.config),
"sitemap" => processor::sitemap::process(value, kind, doc, &self.config),
"get-data" => processor::get_data::process(value, kind, doc, self.config),
"sitemap" => processor::sitemap::process(value, kind, doc, self.config),
"full-sitemap" => {
processor::sitemap::full_sitemap_process(value, kind, doc, &self.config)
processor::sitemap::full_sitemap_process(value, kind, doc, self.config)
}
"request-data" => processor::request_data::process(value, kind, doc, &self.config),
"request-data" => processor::request_data::process(value, kind, doc, self.config),
"document-readers" => processor::document::process_readers(
value,
kind,
doc,
&self.config,
self.config,
self.document_id.as_str(),
),
"document-writers" => processor::document::process_writers(
value,
kind,
doc,
&self.config,
self.config,
self.document_id.as_str(),
),
"user-groups" => processor::user_group::process(value, kind, doc, &self.config),
"user-groups" => processor::user_group::process(value, kind, doc, self.config),
"user-group-by-id" => {
processor::user_group::process_by_id(value, kind, doc, &self.config)
processor::user_group::process_by_id(value, kind, doc, self.config)
}
"get-identities" => {
processor::user_group::get_identities(value, kind, doc, &self.config)
processor::user_group::get_identities(value, kind, doc, self.config)
}
"document-id" => processor::document::document_id(value, kind, doc, &self.config),
"document-id" => processor::document::document_id(value, kind, doc, self.config),
"document-full-id" => {
processor::document::document_full_id(value, kind, doc, &self.config)
processor::document::document_full_id(value, kind, doc, self.config)
}
"document-suffix" => {
processor::document::document_suffix(value, kind, doc, &self.config)
processor::document::document_suffix(value, kind, doc, self.config)
}
"document-name" => {
processor::document::document_name(value, kind, doc, &self.config).await
processor::document::document_name(value, kind, doc, self.config).await
}
"fetch-file" => {
processor::fetch_file::fetch_files(value, kind, doc, &self.config).await
processor::fetch_file::fetch_files(value, kind, doc, self.config).await
}
"user-details" => processor::user_details::process(value, kind, doc, &self.config),
"fastn-apps" => processor::apps::process(value, kind, doc, &self.config),
"is-reader" => processor::user_group::is_reader(value, kind, doc, &self.config).await,
"package-query" => processor::sqlite::process(value, kind, doc, &self.config).await,
"user-details" => processor::user_details::process(value, kind, doc, self.config),
"fastn-apps" => processor::apps::process(value, kind, doc, self.config),
"is-reader" => processor::user_group::is_reader(value, kind, doc, self.config).await,
"package-query" => processor::sqlite::process(value, kind, doc, self.config).await,
"pg" => processor::pg::process(value, kind, doc).await,
"package-tree" => {
processor::package_tree::process(value, kind, doc, &self.config.config).await
processor::package_tree::process(value, kind, doc, self.config.config).await
}
"query" => {
processor::query::process(
value,
kind,
doc,
&mut self.config,
self.config,
self.document_id.as_str(),
)
.await
Expand Down
4 changes: 1 addition & 3 deletions ftd/src/ftd2021/p1/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,15 +815,13 @@ mod test {
),
super::Section::with_name("hello")
.add_sub_section(super::SubSection::with_name("realm.rr.step.body").and_body(
&indoc!(
r#"
r#"
{
"body": "-- h0: Hello World\n\n-- markup:\n\ndemo cr 1\n",
"kind": "content",
"track": "amitu/index",
"version": "2020-11-16T04:13:14.642892+00:00"
}"#
)
))
.list()
);
Expand Down
12 changes: 4 additions & 8 deletions ftd/src/p1/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,13 @@ fn with_dash_dash() {
),
&ftd::p1::Section::with_name("hello")
.add_sub_section(
ftd::p1::Section::with_name("realm.rr.step.body").and_body(&indoc!(
r#"
ftd::p1::Section::with_name("realm.rr.step.body").and_body(r#"
{
"body": "-- h0: Hello World\n\n-- markup:\n\ndemo cr 1\n",
"kind": "content",
"track": "amitu/index",
"version": "2020-11-16T04:13:14.642892+00:00"
}"#,
)),
}"#),
)
.list(),
);
Expand All @@ -472,17 +470,15 @@ fn with_dash_dash() {
#[test]
fn indented_body() {
p(
&indoc!(
"
"
-- markup:
hello world is
not enough
lol
"
),
",
&ftd::p1::Section::with_name("markup")
.and_body("hello world is\n\n not enough\n\n lol")
.list(),
Expand Down

0 comments on commit 58a32df

Please sign in to comment.