diff --git a/src/components/button_primary.rs b/src/components/button_primary.rs index 7fe01c2..ee869d0 100644 --- a/src/components/button_primary.rs +++ b/src/components/button_primary.rs @@ -12,7 +12,7 @@ pub(crate) fn ButtonPrimary( button { class: format!( "cursor-pointer pb-[6px] hover:pb-[7px] active:pb-[2px] mt-[1px] hover:mt-0 active:mt-[5px] hover:*:drop-shadow-[0_1px_0_var(--color-amber-700-muted),0_1px_0_var(--color-amber-700-muted),0_1px_0_var(--color-amber-700-muted),0_1px_0_var(--color-amber-700-muted),0_1px_0_var(--color-amber-700-muted),0_1px_0_var(--color-amber-700-muted),0_1px_0_var(--color-amber-700-muted)] active:*:drop-shadow-[0_1px_0_var(--color-amber-700-muted),0_1px_0_var(--color-amber-700-muted)] transition-all duration-150 {}", - class.unwrap_or("".to_owned()) + class.unwrap_or(String::new()) ), onclick: move |event| { if let Some(onclick) = onclick { diff --git a/src/components/button_secondary.rs b/src/components/button_secondary.rs index 4be48a0..9b7cbc6 100644 --- a/src/components/button_secondary.rs +++ b/src/components/button_secondary.rs @@ -12,7 +12,7 @@ pub(crate) fn ButtonSecondary( button { class: format!( "cursor-pointer pb-[6px] hover:pb-[7px] active:pb-[2px] mt-[1px] hover:mt-0 active:mt-[5px] hover:*:drop-shadow-[0_7px_0_var(--color-gray-800)] active:*:drop-shadow-[0_2px_0_var(--color-gray-800)] transition-all duration-150 {}", - class.unwrap_or("".to_owned()) + class.unwrap_or(String::new()) ), onclick: move |event| { if let Some(onclick) = onclick { diff --git a/src/components/category_input.rs b/src/components/category_input.rs index 9420271..b459da5 100644 --- a/src/components/category_input.rs +++ b/src/components/category_input.rs @@ -19,35 +19,35 @@ pub(crate) fn CategoryInput( SelectButton { icon: FaLightbulb, is_selected: matches!(selected_category(), Category::SomedayMaybe), - on_select: move |_| { + on_select: move |()| { selected_category.set(Category::SomedayMaybe); } } SelectButton { icon: FaWater, is_selected: matches!(selected_category(), Category::LongTerm), - on_select: move |_| { + on_select: move |()| { selected_category.set(Category::LongTerm); } } SelectButton { icon: FaHourglassHalf, is_selected: matches!(selected_category(), Category::WaitingFor(_)), - on_select: move |_| { + on_select: move |()| { selected_category.set(Category::WaitingFor(String::new())); } } SelectButton { icon: FaSignsPost, is_selected: matches!(selected_category(), Category::NextSteps), - on_select: move |_| { + on_select: move |()| { selected_category.set(Category::NextSteps); } } SelectButton { icon: FaCalendarDays, is_selected: matches!(selected_category(), Category::Calendar { .. }), - on_select: move |_| { + on_select: move |()| { selected_category.set(Category::Calendar { date: chrono::Local::now().date_naive(), reoccurrence: None, @@ -58,7 +58,7 @@ pub(crate) fn CategoryInput( SelectButton { icon: FaInbox, is_selected: matches!(selected_category(), Category::Inbox), - on_select: move |_| { + on_select: move |()| { selected_category.set(Category::Inbox); } } diff --git a/src/components/input.rs b/src/components/input.rs index 91aad72..c373594 100644 --- a/src/components/input.rs +++ b/src/components/input.rs @@ -27,11 +27,11 @@ pub(crate) fn Input( "text" | "number" => "", _ => "enabled:cursor-pointer" }, - class.unwrap_or("".to_owned()) + class.unwrap_or(String::new()) ), name: name.clone(), r#type, - id: id.unwrap_or(format!("input_{}", name)), + id: id.unwrap_or(format!("input_{name}")), oninput: move |event| { if let Some(oninput) = oninput { oninput.call(event); diff --git a/src/components/project_form.rs b/src/components/project_form.rs index 5ac7857..c6cff06 100644 --- a/src/components/project_form.rs +++ b/src/components/project_form.rs @@ -47,7 +47,7 @@ pub(crate) fn ProjectForm() -> Element { name: "title", required: true, r#type: "text", - initial_value: project.as_ref().map(|project| project.title.to_owned()), + initial_value: project.as_ref().map(|project| project.title.clone()), } } } diff --git a/src/components/reoccurrence_interval_input.rs b/src/components/reoccurrence_interval_input.rs index 03a6e27..17988d6 100644 --- a/src/components/reoccurrence_interval_input.rs +++ b/src/components/reoccurrence_interval_input.rs @@ -14,28 +14,28 @@ pub(crate) fn ReoccurrenceIntervalInput( SelectButton { icon: FaBan, is_selected: reoccurrence_interval().is_none(), - on_select: move |_| { + on_select: move |()| { reoccurrence_interval.set(None); } } SelectButton { icon: FaSun, is_selected: matches!(reoccurrence_interval(), Some(ReoccurrenceInterval::Day)), - on_select: move |_| { - reoccurrence_interval.set(Some(ReoccurrenceInterval::Day)) + on_select: move |()| { + reoccurrence_interval.set(Some(ReoccurrenceInterval::Day)); } } SelectButton { icon: FaMoon, is_selected: matches!(reoccurrence_interval(), Some(ReoccurrenceInterval::Month)), - on_select: move |_| { + on_select: move |()| { reoccurrence_interval.set(Some(ReoccurrenceInterval::Month)); } } SelectButton { icon: FaEarthEurope, is_selected: matches!(reoccurrence_interval(), Some(ReoccurrenceInterval::Year)), - on_select: move |_| { + on_select: move |()| { reoccurrence_interval.set(Some(ReoccurrenceInterval::Year)); } } diff --git a/src/components/task_form.rs b/src/components/task_form.rs index 5c6eb3e..9d66b24 100644 --- a/src/components/task_form.rs +++ b/src/components/task_form.rs @@ -306,7 +306,7 @@ pub(crate) fn TaskForm() -> Element { name: "category_calendar_reminder_offset_index", r#type: "range", min: 0, - max: REMINDER_OFFSETS.len() as i64 - 1, + max: REMINDER_OFFSETS.len() as i128 - 1, initial_value: category_calendar_reminder_offset_index() .to_string(), oninput: move |event| { @@ -319,13 +319,14 @@ pub(crate) fn TaskForm() -> Element { class: "pr-3 min-w-16 text-right", r#for: "category_calendar_reminder_offset_index", {REMINDER_OFFSETS[category_calendar_reminder_offset_index()] - .map( + .map_or( + t!("none"), |offset| if offset.num_hours() < 1 { format!("{} min", offset.num_minutes()) } else { format!("{} h", offset.num_hours()) } - ).unwrap_or_else(|| t!("none"))} + )} } } } @@ -359,7 +360,7 @@ pub(crate) fn TaskForm() -> Element { delete_task(task.id).await } else { let new_task = NewTask { - title: task.title.to_owned(), + title: task.title.clone(), deadline: task.deadline, category: Category::Trash, project_id: task.project_id diff --git a/src/hooks/mod.rs b/src/hooks/mod.rs index efc31dc..164a2fe 100644 --- a/src/hooks/mod.rs +++ b/src/hooks/mod.rs @@ -14,7 +14,7 @@ use crate::{ }; fn use_on_document_become_visible(mut callback: impl FnMut() + 'static) { - let callback = use_callback(move |_| callback()); + let callback = use_callback(move |()| callback()); use_effect(move || { spawn(async move { let mut eval = document::eval( diff --git a/src/internationalization/mod.rs b/src/internationalization/mod.rs index 512a9f0..ef2b6a6 100644 --- a/src/internationalization/mod.rs +++ b/src/internationalization/mod.rs @@ -28,7 +28,7 @@ impl From> for Locale { fn from(language_identifier: LocaleFromLanguageIdentifier) -> Self { language_identifier .to_string() - .replace("-", "_") + .replace('-', "_") .parse() .unwrap() } diff --git a/src/main.rs b/src/main.rs index 968ed5a..f25db3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,8 @@ +#![warn(clippy::pedantic)] +#![allow(clippy::unused_async)] +// TODO: Enable once false positives are fixed. +#![allow(clippy::assigning_clones)] + mod components; mod dotenv; mod hooks; diff --git a/src/models/category.rs b/src/models/category.rs index d889e3c..5dac259 100644 --- a/src/models/category.rs +++ b/src/models/category.rs @@ -41,6 +41,7 @@ pub enum Category { #[cfg(feature = "server")] impl Category { pub fn eq_sql_predicate(&self) -> Box> { + #![allow(clippy::wildcard_imports)] use crate::schema::tasks::dsl::*; match self { diff --git a/src/server/mod.rs b/src/server/mod.rs index e8a37b5..0f678ff 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,3 +1,6 @@ +// For Diesel DSL. +#![allow(clippy::wildcard_imports)] + #[cfg(feature = "server")] pub(crate) mod database_connection; pub(crate) mod projects; diff --git a/src/server/tasks.rs b/src/server/tasks.rs index 52519e2..fc23289 100644 --- a/src/server/tasks.rs +++ b/src/server/tasks.rs @@ -138,7 +138,7 @@ pub(crate) async fn complete_task(task_id: i32) -> Result { } = &mut new_task.category { match reoccurrence.interval { - ReoccurrenceInterval::Day => *date = *date + Days::new(reoccurrence.length as u64), + ReoccurrenceInterval::Day => *date = *date + Days::new(u64::from(reoccurrence.length)), ReoccurrenceInterval::Month | ReoccurrenceInterval::Year => { *date = *date + Months::new( @@ -152,13 +152,13 @@ pub(crate) async fn complete_task(task_id: i32) -> Result { *date = NaiveDate::from_ymd_opt( date.year(), date.month(), - reoccurrence.start_date.day().min( - Month::try_from(date.month() as u8) + reoccurrence.start_date.day().min(u32::from( + Month::try_from(u8::try_from(date.month()).unwrap()) .unwrap() - .length(date.year()) as u32, - ), + .length(date.year()), + )), ) - .unwrap() + .unwrap(); } } restore_subtasks_of_task(task_id).await?;