Fix cargo clippy issues
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-08-28 08:15:50 +02:00
parent 6e53486832
commit 0540f515ec
6 changed files with 29 additions and 43 deletions

View File

@@ -34,18 +34,16 @@ impl AccommodationRequest {
}
accommodation.name = self.name;
if let Some(d) = &self.description {
if !c.accommodation_description_len.validate(d) {
if let Some(d) = &self.description
&& !c.accommodation_description_len.validate(d) {
return Err(AccommodationListControllerErr::InvalidDescriptionLength.into());
}
}
accommodation.description.clone_from(&self.description);
if let Some(c) = &self.color {
if !lazy_regex::regex!("[a-fA-F0-9]{6}").is_match(c) {
if let Some(c) = &self.color
&& !lazy_regex::regex!("[a-fA-F0-9]{6}").is_match(c) {
return Err(AccommodationListControllerErr::MalformedColor.into());
}
}
accommodation.color.clone_from(&self.color);
accommodation.need_validation = self.need_validation;

View File

@@ -48,23 +48,20 @@ impl CoupleRequest {
}
}
if let Some(husband) = self.husband {
if !members_service::exists(couple.family_id(), husband).await? {
if let Some(husband) = self.husband
&& !members_service::exists(couple.family_id(), husband).await? {
return Err(CoupleControllerErr::HusbandNotExisting.into());
}
}
if let Some(d) = &self.wedding {
if !d.check() {
if let Some(d) = &self.wedding
&& !d.check() {
return Err(CoupleControllerErr::MalformedDateOfWedding.into());
}
}
if let Some(d) = &self.divorce {
if !d.check() {
if let Some(d) = &self.divorce
&& !d.check() {
return Err(CoupleControllerErr::MalformedDateOfDivorce.into());
}
}
couple.set_wife(self.wife);
couple.set_husband(self.husband);

View File

@@ -95,11 +95,10 @@ fn check_opt_str_val(
c: SizeConstraint,
err: MemberControllerErr,
) -> anyhow::Result<()> {
if let Some(v) = val {
if !c.validate(v) {
if let Some(v) = val
&& !c.validate(v) {
return Err(err.into());
}
}
Ok(())
}
@@ -151,11 +150,10 @@ impl MemberRequest {
MemberControllerErr::MalformedEmailAddress,
)?;
if let Some(mail) = &self.email {
if !mailchecker::is_valid(mail) {
if let Some(mail) = &self.email
&& !mailchecker::is_valid(mail) {
return Err(MemberControllerErr::InvalidEmailAddress.into());
}
}
check_opt_str_val(
&self.phone,
@@ -187,23 +185,20 @@ impl MemberRequest {
MemberControllerErr::MalformedCountry,
)?;
if let Some(c) = &self.country {
if !countries_utils::is_code_valid(c) {
if let Some(c) = &self.country
&& !countries_utils::is_code_valid(c) {
return Err(MemberControllerErr::InvalidCountryCode.into());
}
}
if let Some(d) = &self.birth {
if !d.check() {
if let Some(d) = &self.birth
&& !d.check() {
return Err(MemberControllerErr::MalformedDateOfBirth.into());
}
}
if let Some(d) = &self.death {
if !d.check() {
if let Some(d) = &self.death
&& !d.check() {
return Err(MemberControllerErr::MalformedDateOfDeath.into());
}
}
check_opt_str_val(
&self.note,
@@ -221,11 +216,10 @@ impl MemberRequest {
}
}
if let Some(father) = self.father {
if !members_service::exists(member.family_id(), father).await? {
if let Some(father) = self.father
&& !members_service::exists(member.family_id(), father).await? {
return Err(MemberControllerErr::FatherNotExisting.into());
}
}
member.first_name = self.first_name;
member.last_name = self.last_name;

View File

@@ -36,16 +36,15 @@ async fn get_photo(id: &PhotoIdPath, full_size: bool, req: HttpRequest) -> HttpR
};
// Check if an upload is un-necessary
if let Some(c) = req.headers().get(header::IF_NONE_MATCH) {
if c.to_str().unwrap_or("") == hash {
if let Some(c) = req.headers().get(header::IF_NONE_MATCH)
&& c.to_str().unwrap_or("") == hash {
return Ok(HttpResponse::NotModified().finish());
}
}
if let Some(c) = req.headers().get(header::IF_MODIFIED_SINCE) {
let date_str = c.to_str().unwrap_or("");
if let Ok(date) = httpdate::parse_http_date(date_str) {
if date
if let Ok(date) = httpdate::parse_http_date(date_str)
&& date
.add(Duration::from_secs(1))
.duration_since(UNIX_EPOCH)
.unwrap()
@@ -55,7 +54,6 @@ async fn get_photo(id: &PhotoIdPath, full_size: bool, req: HttpRequest) -> HttpR
return Ok(HttpResponse::NotModified().finish());
}
}
}
let bytes = s3_connection::get_file(&match full_size {
true => photo.photo_path(),

View File

@@ -149,11 +149,10 @@ pub mod loop_detection {
impl LoopStack<'_> {
pub fn contains(&self, id: MemberID) -> bool {
if let Some(ls) = &self.prev {
if ls.contains(id) {
if let Some(ls) = &self.prev
&& ls.contains(id) {
return true;
}
}
self.curr == id
}

View File

@@ -64,7 +64,7 @@ fn redis_key(state: &str) -> String {
format!("oidc-state-{state}")
}
async fn load_provider_info(prov_id: &str) -> anyhow::Result<OpenIDClient> {
async fn load_provider_info(prov_id: &str) -> anyhow::Result<OpenIDClient<'_>> {
let prov = AppConfig::get()
.openid_providers()
.into_iter()