clippy

7bb11b4 · gmorell · 2025-01-01 02:02

14 files +34 -73

Files changed

modified src/db.rs
+0 −1
@@ -1,5 +1,4 @@
1 1 use sea_orm::DatabaseConnection;
2 −use log::info;
3 2 use sea_orm_migration::MigratorTrait;
4 3 use crate::migrator::Migrator;
5 4 use crate::PplError;
modified src/do_init.rs
+24 −38
@@ -1,29 +1,24 @@
1 −use crate::entities::prelude::Ppl;
2 1 use crate::entities::prelude::Traits;
3 −use crate::entities::prelude::{Entitys, TierDefaults, TraitDefaults};
4 −use crate::entities::sig_date::Model;
2 +use crate::entities::prelude::{TierDefaults, TraitDefaults};
5 3 use crate::entities::{
6 − contact, entitys, ppl, relation, sig_date, tier, tier_defaults, trait_defaults, traits,
4 + contact, ppl, relation, sig_date, tier_defaults, trait_defaults, traits,
7 5 };
8 6 use crate::PplError;
9 7 use chrono::NaiveDate;
10 8 use crossterm::event;
11 9 use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
12 −use enum_iterator::{all, cardinality, first, last, next, previous, reverse_all, Sequence};
10 +use enum_iterator::{all, next, previous, Sequence};
13 11 use interim::{parse_date_string, Dialect};
14 −use log::{info, warn};
15 12 use ratatui::{
16 13 prelude::*,
17 14 style::{palette::tailwind::*, Color, Modifier, Style, Stylize},
18 15 widgets::*,
19 16 DefaultTerminal,
20 17 };
21 −use sea_orm::prelude::Date;
22 18 use sea_orm::sqlx::types::chrono::Local;
23 −use sea_orm::sqlx::types::{chrono, time};
19 +use sea_orm::sqlx::types::chrono;
24 20 use sea_orm::ActiveValue::Set;
25 −use sea_orm::{ActiveModelTrait, DatabaseConnection, DbErr, EntityTrait, InsertResult};
26 −use std::collections::{BTreeMap, HashMap};
21 +use sea_orm::{ActiveModelTrait, DatabaseConnection, EntityTrait};
27 22 use std::fmt;
28 23 use std::string::String;
29 24 use tui_input::backend::crossterm::EventHandler;
@@ -174,14 +169,11 @@ impl Default for Init {
174 169 impl Init {
175 170 fn toggle_tier(&mut self) {
176 171 let selection = self.tier_state.selected();
177 − match selection {
178 − Some(s) => {
179 − self.tier_list[s].selection = match self.tier_list[s].selection {
180 − Selection::Selected => Selection::NotSelected,
181 − Selection::NotSelected => Selection::Selected,
182 − }
172 + if let Some(s) = selection {
173 + self.tier_list[s].selection = match self.tier_list[s].selection {
174 + Selection::Selected => Selection::NotSelected,
175 + Selection::NotSelected => Selection::Selected,
183 176 }
184 − None => {}
185 177 }
186 178 }
187 179
@@ -212,14 +204,11 @@ impl Init {
212 204
213 205 fn toggle_trait(&mut self) {
214 206 let selection = self.trait_state.selected();
215 − match selection {
216 − Some(s) => {
217 − self.trait_list[s].selection = match self.trait_list[s].selection {
218 − Selection::Selected => Selection::NotSelected,
219 − Selection::NotSelected => Selection::Selected,
220 − }
207 + if let Some(s) = selection {
208 + self.trait_list[s].selection = match self.trait_list[s].selection {
209 + Selection::Selected => Selection::NotSelected,
210 + Selection::NotSelected => Selection::Selected,
221 211 }
222 − None => {}
223 212 }
224 213 }
225 214
@@ -282,7 +271,7 @@ pub async fn run_init(
282 271 app.step = next(&app.step).unwrap();
283 272 }
284 273 Steps::Name => {
285 − if app.input.value() != "".to_string() {
274 + if app.input.value() != "" {
286 275 let all_text = app.input.value();
287 276 let mut split = all_text.split(",").collect::<Vec<&str>>();
288 277 match split.len() {
@@ -305,7 +294,7 @@ pub async fn run_init(
305 294 }
306 295 }
307 296 Steps::Birthday => {
308 − if app.input.value() != "".to_string() {
297 + if app.input.value() != "" {
309 298 let datestr = app.input.value();
310 299 let parsed = parse_date_string(datestr, Local::now(), Dialect::Us);
311 300 match parsed {
@@ -322,14 +311,14 @@ pub async fn run_init(
322 311 }
323 312 }
324 313 Steps::Place => {
325 − if app.input.value() != "".to_string() {
314 + if app.input.value() != "" {
326 315 app.place = app.input.value().into();
327 316 app.input.reset();
328 317 app.step = next(&app.step).unwrap();
329 318 }
330 319 }
331 320 Steps::Of => {
332 − if app.input.value() != "".to_string() {
321 + if app.input.value() != "" {
333 322 app.of_ppl = app
334 323 .input
335 324 .value()
@@ -389,7 +378,7 @@ pub async fn run_init(
389 378 .iter()
390 379 .map(|alias| traits::ActiveModel {
391 380 id: Default::default(),
392 − ppl_id: Set(pp.id.clone()),
381 + ppl_id: Set(pp.id),
393 382 key: Set("alias".to_string()),
394 383 value: Set(alias.clone()),
395 384 hidden: Set(false),
@@ -412,8 +401,8 @@ pub async fn run_init(
412 401
413 402 let b = sig_date::ActiveModel {
414 403 id: Default::default(),
415 − ppl_id: Set(pp.id.clone()),
416 − date: Set(app.bday.clone()),
404 + ppl_id: Set(pp.id),
405 + date: Set(app.bday),
417 406 event: Set("birthday".to_string()),
418 407 do_remind: Set(true),
419 408 with_ppl: Default::default(),
@@ -433,7 +422,7 @@ pub async fn run_init(
433 422 //
434 423 let pl = contact::ActiveModel {
435 424 id: Default::default(),
436 − ppl_id: Set(pp.id.clone()),
425 + ppl_id: Set(pp.id),
437 426 r#type: Set("address".to_string()),
438 427 designator: Default::default(),
439 428 value: Set(app.place.clone()),
@@ -698,10 +687,7 @@ pub async fn run_init(
698 687 app.input.handle_event(&Event::Key(key_event));
699 688 }
700 689 },
701 − KeyCode::Tab => match &app.step {
702 − Steps::Tiers => app.toggle_tier_editing(),
703 − _ => {}
704 − },
690 + KeyCode::Tab => if app.step == Steps::Tiers { app.toggle_tier_editing() },
705 691 // app.input.handle_event(&Event::Key(key));
706 692 // KeyCode::Left => self.decrement_counter(),
707 693 // KeyCode::Right => self.increment_counter(),
@@ -771,7 +757,7 @@ fn render(f: &mut Frame, app: &mut Init) {
771 757
772 758 let scroll = app.input.visual_scroll(width as usize);
773 759
774 − let ival = app.input.value().clone();
760 + let ival = app.input.value();
775 761 let input = Paragraph::new(ival)
776 762 .style(Style::default())
777 763 // .style(match app.input_mode {
@@ -783,7 +769,7 @@ fn render(f: &mut Frame, app: &mut Init) {
783 769
784 770 let mname: String = app.name.clone();
785 771 let mnicks: String = app.aliases.join(", ");
786 − let mbday = app.bday.clone();
772 + let mbday = app.bday;
787 773 let mplace = app.place.clone();
788 774 let mut messages = vec![
789 775 ("name".to_string(), mname),
modified src/main.rs
+4 −16
@@ -1,28 +1,16 @@
1 1 use clap::{Parser, Subcommand};
2 −use crossterm::{
3 − event::{self, Event, KeyCode},
4 − terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
5 − ExecutableCommand,
6 −};
7 −use futures::executor::block_on;
2 +use crossterm::event::{Event};
8 3 use log::info;
9 −use ratatui::{prelude::*, widgets::*, DefaultTerminal};
10 4 use sea_orm::*;
11 −use sea_orm_migration::SchemaManager;
12 −use std::io::{self, stdout};
5 +use std::io::{self};
13 6 use color_eyre::eyre::ErrReport;
14 −use Event::Key;
15 7
16 8 mod entities;
17 9 mod migrator;
18 10 mod db;
19 11 mod do_init;
20 12
21 −use crate::entities::ppl::Model as PplModel;
22 −use crate::entities::tier_defaults::Model as TiDModel;
23 −use crate::entities::trait_defaults::Model as TrDModel;
24 −use crate::migrator::Migrator;
25 −use entities::{prelude::*, *};
13 +use entities::prelude::*;
26 14 use crate::entities::ppl::Column::Me;
27 15
28 16 #[derive(Debug)]
@@ -124,7 +112,7 @@ async fn main() -> Result<(), PplError> {
124 112 let terminal = ratatui::init();
125 113 let result = do_init::run_init(terminal, db).await;
126 114 ratatui::restore();
127 − result;
115 + drop(result);
128 116 info!("Init complete");
129 117 }
130 118 true => {
modified src/migrator/m20241220_000002_create_contact.rs
+0 −2
@@ -1,5 +1,3 @@
1 −use crate::migrator::m20241219_000001_create_ppl::Ppl;
2 −use crate::migrator::m20241220_000003_create_entity::Entitys;
3 1 use sea_orm_migration::prelude::*;
4 2
5 3 pub struct Migration;
modified src/migrator/m20241220_000003_create_entity.rs
+0 −2
@@ -1,5 +1,3 @@
1 −use crate::migrator::m20241219_000001_create_ppl::Ppl;
2 −use crate::migrator::m20241220_000002_create_contact::Contact;
3 1 use sea_orm_migration::prelude::*;
4 2
5 3 pub struct Migration;
modified src/migrator/m20241220_000004_create_sig_date.rs
+1 −2

Click to load diff…

modified src/migrator/m20241220_000005_create_trait.rs
+1 −3

Click to load diff…

modified src/migrator/m20241220_000006_create_relation.rs
+1 −3

Click to load diff…

modified src/migrator/m20241220_000007_create_tier.rs
+1 −3

Click to load diff…

modified src/migrator/m20241222_000008_create_traitsettings.rs
+1 −1

Click to load diff…

modified src/migrator/m20241222_000009_create_tiersettings.rs
+1 −1

Click to load diff…

modified src/migrator/mod.rs
+0 −1

Click to load diff…

Parents: 28d075f