Skip to content

Commit

Permalink
Fixing clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-hughes committed Sep 26, 2021
1 parent 8865f96 commit 12b036b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Database {
let pod_id = stmt.query_row::<i64, _, _>(params![podcast.url], |row| row.get(0))?;
let mut ep_ids = Vec::new();
for ep in podcast.episodes.iter().rev() {
let id = self.insert_episode(pod_id, &ep)?;
let id = self.insert_episode(pod_id, ep)?;
let new_ep = NewEpisode {
id: id,
pod_id: pod_id,
Expand Down Expand Up @@ -389,7 +389,7 @@ impl Database {
}
}
None => {
let id = self.insert_episode(podcast_id, &new_ep)?;
let id = self.insert_episode(podcast_id, new_ep)?;
let new_ep = NewEpisode {
id: id,
pod_id: podcast_id,
Expand Down Expand Up @@ -520,7 +520,7 @@ impl Database {
url: row.get("url")?,
guid: row
.get::<&str, Option<String>>("guid")?
.unwrap_or("".to_string()),
.unwrap_or_else(|| "".to_string()),
description: row.get("description")?,
pubdate: convert_date(row.get("pubdate")),
duration: row.get("duration")?,
Expand Down
2 changes: 1 addition & 1 deletion src/feeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn parse_episode_data(item: &Item) -> EpisodeNoId {
fn duration_to_int(duration: Option<&str>) -> Option<i32> {
match duration {
Some(dur) => {
match RE_DURATION.captures(&dur) {
match RE_DURATION.captures(dur) {
Some(cap) => {
/*
* Provided that the regex succeeds, we should have
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ fn import(db_path: &Path, config: Config, args: &clap::ArgMatches) -> Result<()>
/// Exports all podcasts to OPML format, either printing to stdout or
/// exporting to a file.
fn export(db_path: &Path, args: &clap::ArgMatches) -> Result<()> {
let db_inst = Database::connect(&db_path)?;
let db_inst = Database::connect(db_path)?;
let podcast_list = db_inst.get_podcasts()?;
let opml = opml::export(podcast_list);

Expand Down
5 changes: 3 additions & 2 deletions src/main_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::types::*;
use crate::ui::{Ui, UiMsg};

/// Enum used for communicating with other threads.
#[allow(clippy::enum_variant_names)]
#[derive(Debug)]
pub enum MainMessage {
UiUpdateMenus,
Expand Down Expand Up @@ -52,7 +53,7 @@ impl MainController {
let (tx_to_main, rx_to_main) = mpsc::channel();

// get connection to the database
let db_inst = Database::connect(&db_path)?;
let db_inst = Database::connect(db_path)?;

// set up threadpool
let threadpool = Threadpool::new(config.simultaneous_downloads);
Expand Down Expand Up @@ -362,7 +363,7 @@ impl MainController {
// if there is a local file, try to play that
Some(path) => match path.to_str() {
Some(p) => {
if play_file::execute(&self.config.play_command, &p).is_err() {
if play_file::execute(&self.config.play_command, p).is_err() {
self.notif_to_ui(
"Error: Could not play file. Check configuration.".to_string(),
true,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl AppColors {
}
return Err(anyhow!("Invalid color hex code"));
} else if text.starts_with("rgb") || text.starts_with("RGB") {
#[allow(clippy::clippy::from_str_radix_10)]
#[allow(clippy::from_str_radix_10)]
if let Some(cap) = RE_COLOR_RGB.captures(text) {
return Ok(Color::Rgb {
r: u8::from_str_radix(&cap[1], 10)?,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<T: Clone + Menuable> Menu<T> {
// for visible rows, print strings from list
for i in self.start_row..self.panel.get_rows() {
if let Some(elem_id) = order.get(self.get_menu_idx(i)) {
let elem = map.get(&elem_id).expect("Could not retrieve menu item.");
let elem = map.get(elem_id).expect("Could not retrieve menu item.");

if i == self.selected || !elem.is_played() {
let style = if !elem.is_played() {
Expand Down
6 changes: 2 additions & 4 deletions src/ui/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,15 @@ impl NotifWin {
}
}
KeyCode::Char(c) => {
current_max_x += 1;
cursor_x += 1;
if cursor_x < current_max_x {
current_max_x += 1;
cursor_x += 1;
inputs.insert(cursor_idx, c);
for i in inputs.chars().skip(cursor_idx) {
execute!(io::stdout(), style::Print(i)).unwrap();
}
execute!(io::stdout(), cursor::MoveTo(cursor_x, self.start_y)).unwrap();
} else {
current_max_x += 1;
cursor_x += 1;
inputs.push(c);
execute!(io::stdout(), style::Print(c)).unwrap();
}
Expand Down

0 comments on commit 12b036b

Please sign in to comment.