Fix clippy warnings and make them all errors

This commit is contained in:
Dustin J. Mitchell 2020-12-24 17:39:49 +00:00
parent 161c38807d
commit 8989b0d2e3
12 changed files with 24 additions and 23 deletions

View file

@ -13,7 +13,7 @@ pub(crate) fn execute<W: WriteColor>(
_ => "(no description)".to_owned(), _ => "(no description)".to_owned(),
}; };
let t = replica.new_task(Status::Pending, description).unwrap(); let t = replica.new_task(Status::Pending, description).unwrap();
write!(w, "added task {}\n", t.get_uuid())?; writeln!(w, "added task {}", t.get_uuid())?;
Ok(()) Ok(())
} }

View file

@ -4,7 +4,7 @@ use termcolor::WriteColor;
pub(crate) fn execute<W: WriteColor>(w: &mut W, replica: &mut Replica) -> Fallible<()> { pub(crate) fn execute<W: WriteColor>(w: &mut W, replica: &mut Replica) -> Fallible<()> {
replica.gc()?; replica.gc()?;
write!(w, "garbage collected.\n")?; writeln!(w, "garbage collected.")?;
Ok(()) Ok(())
} }

View file

@ -8,7 +8,7 @@ pub(crate) fn execute<W: WriteColor>(
server: &mut Box<dyn Server>, server: &mut Box<dyn Server>,
) -> Fallible<()> { ) -> Fallible<()> {
replica.sync(server)?; replica.sync(server)?;
write!(w, "sync complete.\n")?; writeln!(w, "sync complete.")?;
Ok(()) Ok(())
} }

View file

@ -4,7 +4,7 @@ use termcolor::{ColorSpec, WriteColor};
pub(crate) fn execute<W: WriteColor>(w: &mut W) -> Fallible<()> { pub(crate) fn execute<W: WriteColor>(w: &mut W) -> Fallible<()> {
write!(w, "TaskChampion ")?; write!(w, "TaskChampion ")?;
w.set_color(ColorSpec::new().set_bold(true))?; w.set_color(ColorSpec::new().set_bold(true))?;
write!(w, "{}\n", env!("CARGO_PKG_VERSION"))?; writeln!(w, "{}", env!("CARGO_PKG_VERSION"))?;
w.reset()?; w.reset()?;
Ok(()) Ok(())
} }

View file

@ -18,10 +18,7 @@ pub(super) fn filtered_tasks(
let mut res = vec![]; let mut res = vec![];
fn is_partial_uuid(taskid: &TaskId) -> bool { fn is_partial_uuid(taskid: &TaskId) -> bool {
match taskid { matches!(taskid, TaskId::PartialUuid(_))
TaskId::PartialUuid(_) => true,
_ => false,
}
} }
// We will enumerate the universe of tasks for this filter, checking // We will enumerate the universe of tasks for this filter, checking
@ -32,7 +29,7 @@ pub(super) fn filtered_tasks(
Universe::IdList(ref ids) if ids.iter().any(is_partial_uuid) => { Universe::IdList(ref ids) if ids.iter().any(is_partial_uuid) => {
'task: for (uuid, task) in replica.all_tasks()?.drain() { 'task: for (uuid, task) in replica.all_tasks()?.drain() {
for id in ids { for id in ids {
if match id { let in_universe = match id {
TaskId::WorkingSetId(id) => { TaskId::WorkingSetId(id) => {
// NOTE: (#108) this results in many reads of the working set; it // NOTE: (#108) this results in many reads of the working set; it
// may be better to cache this information here or in the Replica. // may be better to cache this information here or in the Replica.
@ -40,15 +37,14 @@ pub(super) fn filtered_tasks(
} }
TaskId::PartialUuid(prefix) => uuid.to_string().starts_with(prefix), TaskId::PartialUuid(prefix) => uuid.to_string().starts_with(prefix),
TaskId::Uuid(id) => id == &uuid, TaskId::Uuid(id) => id == &uuid,
} { };
if match_task(filter, &task) { if in_universe && match_task(filter, &task) {
res.push(task); res.push(task);
continue 'task; continue 'task;
} }
} }
} }
} }
}
// A list of full IDs, which we can fetch directly // A list of full IDs, which we can fetch directly
Universe::IdList(ref ids) => { Universe::IdList(ref ids) => {

View file

@ -17,6 +17,7 @@ use filter::filtered_tasks;
use modify::apply_modification; use modify::apply_modification;
/// Invoke the given Command in the context of the given settings /// Invoke the given Command in the context of the given settings
#[allow(clippy::needless_return)]
pub(crate) fn invoke(command: Command, settings: Config) -> Fallible<()> { pub(crate) fn invoke(command: Command, settings: Config) -> Fallible<()> {
log::debug!("command: {:?}", command); log::debug!("command: {:?}", command);
log::debug!("settings: {:?}", settings); log::debug!("settings: {:?}", settings);
@ -88,7 +89,7 @@ pub(crate) fn invoke(command: Command, settings: Config) -> Fallible<()> {
subcommand: Subcommand::Version, subcommand: Subcommand::Version,
.. ..
} => unreachable!(), } => unreachable!(),
} };
} }
// utilities for invoke // utilities for invoke

View file

@ -45,7 +45,7 @@ pub(super) fn apply_modification<W: WriteColor>(
task.remove_tag(&tag)?; task.remove_tag(&tag)?;
} }
write!(w, "modified task {}\n", task.get_uuid())?; writeln!(w, "modified task {}", task.get_uuid())?;
Ok(()) Ok(())
} }

View file

@ -1,3 +1,4 @@
#![deny(clippy::all)]
/*! /*!
This crate implements the command-line interface to TaskChampion. This crate implements the command-line interface to TaskChampion.

View file

@ -38,13 +38,13 @@ impl Usage {
"TaskChampion {}: Personal task-tracking\n\n", "TaskChampion {}: Personal task-tracking\n\n",
env!("CARGO_PKG_VERSION") env!("CARGO_PKG_VERSION")
)?; )?;
write!(w, "USAGE:\n {} [args]\n\n", command_name)?; writeln!(w, "USAGE:\n {} [args]\n", command_name)?;
write!(w, "TaskChampion subcommands:\n")?; writeln!(w, "TaskChampion subcommands:")?;
for subcommand in self.subcommands.iter() { for subcommand in self.subcommands.iter() {
subcommand.write_help(&mut w, summary)?; subcommand.write_help(&mut w, summary)?;
} }
if !summary { if !summary {
write!(w, "\nSee `task help` for more detail\n")?; writeln!(w, "\nSee `task help` for more detail")?;
} }
Ok(()) Ok(())
} }
@ -69,7 +69,7 @@ pub(crate) struct Subcommand {
impl Subcommand { impl Subcommand {
fn write_help<W: Write>(&self, mut w: W, summary: bool) -> Result<()> { fn write_help<W: Write>(&self, mut w: W, summary: bool) -> Result<()> {
if summary { if summary {
write!(w, " task {} - {}\n", self.name, self.summary)?; writeln!(w, " task {} - {}", self.name, self.summary)?;
} else { } else {
write!( write!(
w, w,

View file

@ -1,3 +1,5 @@
#![deny(clippy::all)]
use crate::storage::{KVStorage, Storage}; use crate::storage::{KVStorage, Storage};
use actix_web::{get, web, App, HttpServer, Responder, Scope}; use actix_web::{get, web, App, HttpServer, Responder, Scope};
use api::{api_scope, ServerState}; use api::{api_scope, ServerState};

View file

@ -1,3 +1,4 @@
#![deny(clippy::all)]
/*! /*!
This crate implements the core of TaskChampion, the [replica](crate::Replica). This crate implements the core of TaskChampion, the [replica](crate::Replica).

View file

@ -215,8 +215,8 @@ impl Task {
/// Iterate over the task's tags /// Iterate over the task's tags
pub fn get_tags(&self) -> impl Iterator<Item = Tag> + '_ { pub fn get_tags(&self) -> impl Iterator<Item = Tag> + '_ {
self.taskmap.iter().filter_map(|(k, _)| { self.taskmap.iter().filter_map(|(k, _)| {
if k.starts_with("tag.") { if let Some(tag) = k.strip_prefix("tag.") {
if let Ok(tag) = (&k[4..]).try_into() { if let Ok(tag) = tag.try_into() {
return Some(tag); return Some(tag);
} }
// note that invalid "tag.*" are ignored // note that invalid "tag.*" are ignored
@ -326,7 +326,7 @@ impl<'r> TaskMut<'r> {
if let Some(v) = value { if let Some(v) = value {
trace!("task {}: set property {}={:?}", self.task.uuid, property, v); trace!("task {}: set property {}={:?}", self.task.uuid, property, v);
self.task.taskmap.insert(property.to_string(), v); self.task.taskmap.insert(property, v);
} else { } else {
trace!("task {}: remove property {}", self.task.uuid, property); trace!("task {}: remove property {}", self.task.uuid, property);
self.task.taskmap.remove(&property); self.task.taskmap.remove(&property);