Fix clippy errors + lint, use turbo CI

This commit is contained in:
Jai A
2024-10-18 16:07:35 -07:00
parent 663ab83b08
commit 8dd955563e
186 changed files with 10615 additions and 6433 deletions

View File

@@ -1,6 +1,8 @@
use crate::models::pack::{PackFileHash, PackFormat};
use crate::util::validate::validation_errors_to_string;
use crate::validate::{SupportedGameVersions, ValidationError, ValidationResult};
use crate::validate::{
SupportedGameVersions, ValidationError, ValidationResult,
};
use std::io::{Cursor, Read};
use std::path::Component;
use validator::Validate;
@@ -26,11 +28,14 @@ impl super::Validator for ModpackValidator {
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
) -> Result<ValidationResult, ValidationError> {
let pack: PackFormat = {
let mut file = if let Ok(file) = archive.by_name("modrinth.index.json") {
file
} else {
return Ok(ValidationResult::Warning("Pack manifest is missing."));
};
let mut file =
if let Ok(file) = archive.by_name("modrinth.index.json") {
file
} else {
return Ok(ValidationResult::Warning(
"Pack manifest is missing.",
));
};
let mut contents = String::new();
file.read_to_string(&mut contents)?;
@@ -39,7 +44,9 @@ impl super::Validator for ModpackValidator {
};
pack.validate().map_err(|err| {
ValidationError::InvalidInput(validation_errors_to_string(err, None).into())
ValidationError::InvalidInput(
validation_errors_to_string(err, None).into(),
)
})?;
if pack.game != "minecraft" {
@@ -48,8 +55,12 @@ impl super::Validator for ModpackValidator {
));
}
if pack.files.is_empty() && !archive.file_names().any(|x| x.starts_with("overrides/")) {
return Err(ValidationError::InvalidInput("Pack has no files!".into()));
if pack.files.is_empty()
&& !archive.file_names().any(|x| x.starts_with("overrides/"))
{
return Err(ValidationError::InvalidInput(
"Pack has no files!".into(),
));
}
for file in &pack.files {
@@ -68,7 +79,11 @@ impl super::Validator for ModpackValidator {
let path = std::path::Path::new(&file.path)
.components()
.next()
.ok_or_else(|| ValidationError::InvalidInput("Invalid pack file path!".into()))?;
.ok_or_else(|| {
ValidationError::InvalidInput(
"Invalid pack file path!".into(),
)
})?;
match path {
Component::CurDir | Component::Normal(_) => {}