Skip to content

Commit

Permalink
Always exit when a lint command fails
Browse files Browse the repository at this point in the history
Now that we have an opt-in list for the Clippy, it makes sense to
gradually decrease the accepted lint list so that we won't regress while
migrating.
  • Loading branch information
Xanewok committed Oct 31, 2023
1 parent ef62ad6 commit 4aefb19
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
3 changes: 1 addition & 2 deletions crates/infra/cli/src/commands/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ fn run_clippy() -> Result<()> {
let mut clippy = Command::new("cargo")
.flag("clippy")
.flag("--")
.flag("--verbose")
.exit_on_failure(false);
.flag("--verbose");

for lint in allowed_lints {
clippy = clippy.property("-A", format!("clippy::{}", lint));
Expand Down
18 changes: 1 addition & 17 deletions crates/infra/utils/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub struct Command {
args: Vec<String>,
environment: HashMap<String, String>,
current_dir: Option<PathBuf>,
/// Whether the command failure should cause the entire process to exit.
exit_on_failure: bool,
}

impl Command {
Expand All @@ -34,7 +32,6 @@ impl Command {
args: vec![],
environment: HashMap::new(),
current_dir: None,
exit_on_failure: true,
};
}

Expand Down Expand Up @@ -80,15 +77,6 @@ impl Command {
return self;
}

/// Whether the command failure should cause the entire process to exit.
///
/// Defaults to `true`.
pub fn exit_on_failure(mut self, exit_on_failure: bool) -> Self {
self.exit_on_failure = exit_on_failure;

self
}

pub fn evaluate(&self) -> Result<String> {
let output = spawn_with_defaults(self, Stdio::piped)?
.wait_with_output()
Expand Down Expand Up @@ -146,11 +134,7 @@ fn run_with_defaults(command: &Command) -> Result<()> {
check_status(command, status).map_err(|error| {
// Print error and exit process, to skip printing irrelevant backtraces from the parent process:
eprintln!("{error}");
if command.exit_on_failure {
std::process::exit(1);
} else {
error
}
std::process::exit(1);
})
}

Expand Down

0 comments on commit 4aefb19

Please sign in to comment.