Skip to content

Commit

Permalink
fix cargo clippy, cargo test (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
24seconds authored Mar 7, 2023
1 parent 7227d36 commit 5c2a4c7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/command/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ mod tests {
#[test]
fn test_get_common_subcommands() {
let subcommands = get_common_subcommands();
assert!(subcommands.len() == 6);
assert_eq!(subcommands.len(), 7);
}

#[test]
Expand Down
7 changes: 3 additions & 4 deletions src/command/handler/user_input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use chrono;
use chrono::Utc;
use clap::{ArgMatches, Command, ErrorKind};
use std::process;
Expand Down Expand Up @@ -120,7 +119,7 @@ async fn handle_create(
OutputType::Println,
format!(
"[{}] Notification (id: {}) created",
chrono::offset::Local::now().to_string(),
chrono::offset::Local::now(),
id
),
);
Expand Down Expand Up @@ -176,7 +175,7 @@ async fn handle_queue(
OutputType::Println,
format!(
"[{}] Notification (id: {}) created and queued",
chrono::offset::Local::now().to_string(),
chrono::offset::Local::now(),
id
),
);
Expand Down Expand Up @@ -205,7 +204,7 @@ async fn handle_delete(
OutputType::Println,
format!(
"[{}] Notification (id: {}) deleted",
chrono::offset::Local::now().to_string(),
chrono::offset::Local::now(),
id
),
);
Expand Down
12 changes: 6 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use std::{error::Error, fmt, io, result};
pub type NotifyResult = result::Result<(), NotificationError>;

// TODO(young): Replace main error type to this
enum PomodoroError {
NotificationError,
ConfigurationError,
UdsHandlerError,
UserInputHandlerError,
ParseError,
enum _PomodoroError {
Notification,
Configuration,
UdsHandler,
UserInputHandler,
Parse,
}

// notification error enum
Expand Down
2 changes: 1 addition & 1 deletion src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub async fn create_client_uds() -> Result<UnixDatagram, std::io::Error> {
let client_addr = create_uds_address(UdsType::Client, true)?;

let socket = UnixDatagram::bind(client_addr)?;
let _ = socket.connect(server_addr)?;
socket.connect(server_addr)?;

debug!("create_client_uds called");
Ok(socket)
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async fn main() -> Result<(), Box<dyn Error>> {

let stdin_tx = user_input_tx.clone();
// TODO(young): handle tokio::spawn return value nicely so that we can use `?` inside
let stdinput_handle = spawn_stdinput_handler(stdin_tx);
let _stdinput_handle = spawn_stdinput_handler(stdin_tx);

// handle uds
let uds_input_tx = user_input_tx.clone();
Expand All @@ -83,7 +83,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
Some(uds) => {
let server_uds = Arc::new(uds);
let (server_rx, server_tx) = (server_uds.clone(), server_uds.clone());
let uds_input_handle =
let _uds_input_handle =
spawn_uds_input_handler(uds_input_tx, server_tx, server_rx);

Some(server_uds)
Expand Down Expand Up @@ -299,7 +299,7 @@ fn spawn_uds_input_handler(
let user_input: UserInput = MessageRequest::into(message);
debug!("user_input: {:?}", user_input);

let _ = uds_tx.send(user_input).await.unwrap();
uds_tx.send(user_input).await.unwrap();
}
UdsMessage::Internal(message) => {
debug!("internal_message ok, {:?}", message);
Expand Down
5 changes: 1 addition & 4 deletions src/notification/archived_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ pub struct ArchivedNotification {
description: String,
work_time: u16,
break_time: u16,
// TODO(young): Maybe we don't need created_at field for ArchivedNotification
created_at: DateTime<Utc>,
work_expired_at: DateTime<Utc>,
break_expired_at: DateTime<Utc>,
}

impl From<Notification> for ArchivedNotification {
fn from(n: Notification) -> Self {
let (id, desc, wt, bt, created_at, w_expired_at, b_expired_at) = n.get_values();
let (id, desc, wt, bt, _, w_expired_at, b_expired_at) = n.get_values();

ArchivedNotification {
id,
description: desc.to_string(),
work_time: wt,
break_time: bt,
created_at,
work_expired_at: w_expired_at,
break_expired_at: b_expired_at,
}
Expand Down
3 changes: 2 additions & 1 deletion src/notification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ mod tests {

NaiveDateTime::new(date, time)
};

let row = vec![
Value::I64(0),
Value::Str("sample".to_string()),
Expand All @@ -327,7 +328,7 @@ mod tests {
Value::Timestamp(naive_date_time),
Value::Timestamp(naive_date_time + Duration::minutes(25)),
Value::Timestamp(naive_date_time + Duration::minutes(30)),
];
].into();

Notification::convert_to_notification(row)
};
Expand Down

0 comments on commit 5c2a4c7

Please sign in to comment.