Merge pull request #115 from djmitche/issue110

Fix clippy warnings and make them all errors
This commit is contained in:
Dustin J. Mitchell 2020-12-24 13:30:39 -05:00 committed by GitHub
commit 7594144a2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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(),
};
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(())
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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