Skip to content

Commit

Permalink
Fixes according to Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Lelek committed Jul 17, 2024
1 parent e2ed204 commit 814312c
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions fplus-lib/src/core/allocator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub async fn process_allocator_file(file_name: &str) -> Result<AllocatorModel, L
let branch = "main";
let path = file_name.to_string();

let gh = GithubWrapper::new(owner.clone(), repo.clone(), installation_id.clone());
let gh = GithubWrapper::new(owner.clone(), repo.clone(), installation_id);
let content_items: ContentItems = gh
.get_files_from_public_repo(&owner, &repo, branch, Some(&path))
.await
Expand Down Expand Up @@ -269,7 +269,7 @@ pub async fn init_allocator_repo(gh: &GithubWrapper) -> Result<(), LDNError> {
dirs.push(file_path);
continue;
}
self::create_file_in_repo(&gh, file, false).await?;
self::create_file_in_repo(gh, file, false).await?;
}
}

Expand Down Expand Up @@ -557,9 +557,9 @@ pub async fn create_allocator_from_file(files_changed: Vec<String>) -> Result<()
if allocation_amount.amount_type.clone().is_none()
|| allocation_amount.quantity_options.clone().is_none()
{
return Err(LDNError::New(format!(
"Amount type and quantity options are required"
)));
return Err(LDNError::New(
"Amount type and quantity options are required".to_string(),
));
}

let amount_type = allocation_amount
Expand All @@ -574,7 +574,7 @@ pub async fn create_allocator_from_file(files_changed: Vec<String>) -> Result<()
}

validate_amount_type_and_options(&amount_type, &quantity_options)
.map_err(|e| LDNError::New(format!("{}", e)))?;
.map_err(|e| LDNError::New(e.to_string()))?;

model
.application
Expand Down Expand Up @@ -613,10 +613,10 @@ pub async fn create_allocator_from_file(files_changed: Vec<String>) -> Result<()
)
})
.map_err(|e| {
return LDNError::New(format!(
LDNError::New(format!(
"Installation Id not found for a repo: {} /// {}",
repo, e
));
))
})?;

let gh = GithubWrapper::new(owner.to_string(), repo.to_string(), installation_id);
Expand Down Expand Up @@ -660,20 +660,18 @@ pub async fn create_allocator_from_file(files_changed: Vec<String>) -> Result<()
Some(file_name.to_owned()),
)
.await
.map_err(|e| {
return LDNError::New(format!("Create or update allocator failed: {}", e));
})?;
.map_err(|e| LDNError::New(format!("Create or update allocator failed: {}", e)))?;

let allocator_id = allocator_creation_result.id;

// Delete all old allocation amounts by allocator id
delete_allocation_amounts_by_allocator_id(allocator_id)
.await
.map_err(|e| {
return LDNError::New(format!(
LDNError::New(format!(
"Delete all old allocation amounts by allocator id failed: {}",
e
));
))
})?;

if let Some(allocation_amount) = model.application.allocation_amount.clone() {
Expand All @@ -684,10 +682,10 @@ pub async fn create_allocator_from_file(files_changed: Vec<String>) -> Result<()
create_allocation_amount(allocator_id, parsed_allocation_amount)
.await
.map_err(|e| {
return LDNError::New(format!(
LDNError::New(format!(
"Create allocation amount rows in the database failed: {}",
e
));
))
})?;
}
}
Expand Down

0 comments on commit 814312c

Please sign in to comment.