Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish committed Jul 10, 2018
1 parent 42fa378 commit 84b8f3b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
16 changes: 7 additions & 9 deletions src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ It's dangerous to run yay since Python based AUR packages will be installed in t
}

Command::new(yay).spawn()?.wait()?.check()?;
} else if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["/usr/bin/pacman", "-Syu"])
.spawn()?
.wait()?
.check()?;
} else {
if let Some(sudo) = &sudo {
Command::new(&sudo)
.args(&["/usr/bin/pacman", "-Syu"])
.spawn()?
.wait()?
.check()?;
} else {
terminal.print_warning("No sudo or yay detected. Skipping system upgrade");
}
terminal.print_warning("No sudo or yay detected. Skipping system upgrade");
}

Ok(())
Expand Down
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct StepFailed;
#[fail(display = "Cannot find the user base directories")]
struct NoBaseDirectories;

#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
fn run() -> Result<(), Error> {
let matches = App::new("Topgrade")
.version(crate_version!())
Expand All @@ -65,7 +66,7 @@ fn run() -> Result<(), Error> {
)
.get_matches();

if matches.is_present("tmux") && !env::var("TMUX").is_ok() {
if matches.is_present("tmux") && env::var("TMUX").is_err() {
#[cfg(unix)]
{
unix::run_in_tmux();
Expand Down Expand Up @@ -144,9 +145,7 @@ fn run() -> Result<(), Error> {

for repo in git_repos.repositories() {
terminal.print_separator(format!("Pulling {}", repo));
if let Some(success) = git.pull(&repo).ok().and_then(|i| i) {
success.report(format!("git: {}", repo), &mut reports);
}
git.pull(&repo).report(format!("git: {}", repo), &mut reports);
}

#[cfg(unix)]
Expand Down
2 changes: 1 addition & 1 deletion src/steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn run_vim(vim: &PathBuf, vimrc: &PathBuf, upgrade_command: &str) -> Result<
.wait()?
.check()?;

println!("");
println!();

Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ impl Terminal {
Some(width) => {
let _ = self.stdout
.set_color(ColorSpec::new().set_fg(Some(Color::White)).set_bold(true));
let _ = write!(
let _ = writeln!(
&mut self.stdout,
"\n―― {} {:―^border$}\n",
"\n―― {} {:―^border$}",
message,
"",
border = max(2, min(80, width as usize) - 3 - message.len())
Expand All @@ -33,7 +33,7 @@ impl Terminal {
let _ = self.stdout.flush();
}
None => {
let _ = write!(&mut self.stdout, "―― {} ――\n", message);
let _ = writeln!(&mut self.stdout, "―― {} ――", message);
}
}
}
Expand All @@ -44,7 +44,7 @@ impl Terminal {

let _ = self.stdout
.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)).set_bold(true));
let _ = write!(&mut self.stdout, "{}\n", message);
let _ = writeln!(&mut self.stdout, "{}", message);
let _ = self.stdout.reset();
let _ = self.stdout.flush();
}
Expand All @@ -59,7 +59,7 @@ impl Terminal {
.set_bold(true),
);

let _ = write!(&mut self.stdout, "{}\n", if succeeded { "OK" } else { "FAILED" });
let _ = writeln!(&mut self.stdout, "{}", if succeeded { "OK" } else { "FAILED" });

let _ = self.stdout.reset();
let _ = self.stdout.flush();
Expand Down

0 comments on commit 84b8f3b

Please sign in to comment.