Skip to content

Commit 194a5ff

Browse files
committedJan 29, 2025·
refactor(linter): remove LintResult (#8712)
1 parent ad35e82 commit 194a5ff

File tree

3 files changed

+16
-37
lines changed

3 files changed

+16
-37
lines changed
 

Diff for: ‎apps/oxlint/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,5 @@ mod walk;
88

99
pub mod cli {
1010

11-
pub use crate::{
12-
command::*,
13-
lint::LintRunner,
14-
result::{CliRunResult, LintResult},
15-
runner::Runner,
16-
};
11+
pub use crate::{command::*, lint::LintRunner, result::CliRunResult, runner::Runner};
1712
}

Diff for: ‎apps/oxlint/src/lint.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use oxc_span::VALID_EXTENSIONS;
1616
use serde_json::Value;
1717

1818
use crate::{
19-
cli::{CliRunResult, LintCommand, LintResult, MiscOptions, Runner, WarningOptions},
19+
cli::{CliRunResult, LintCommand, MiscOptions, Runner, WarningOptions},
2020
output_formatter::{LintCommandInfo, OutputFormatter},
2121
walk::{Extensions, Walk},
2222
};
@@ -80,7 +80,7 @@ impl Runner for LintRunner {
8080
// filtered, return early.
8181
if provided_path_count > 0 {
8282
// ToDo: when oxc_linter (config) validates the configuration, we can use exit_code = 1 to fail
83-
return CliRunResult::LintResult(LintResult::default());
83+
return CliRunResult::LintResult(ExitCode::SUCCESS);
8484
}
8585

8686
paths.push(self.cwd.clone());
@@ -226,12 +226,7 @@ impl Runner for LintRunner {
226226
stdout.write_all(end.as_bytes()).or_else(Self::check_for_writer_error).unwrap();
227227
};
228228

229-
CliRunResult::LintResult(LintResult {
230-
number_of_files,
231-
number_of_warnings: diagnostic_result.warnings_count(),
232-
number_of_errors: diagnostic_result.errors_count(),
233-
exit_code: ExitCode::from(u8::from(diagnostic_failed)),
234-
})
229+
CliRunResult::LintResult(ExitCode::from(u8::from(diagnostic_failed)))
235230
}
236231
}
237232

Diff for: ‎apps/oxlint/src/result.rs

+12-23
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,18 @@ use std::{
66
#[derive(Debug)]
77
pub enum CliRunResult {
88
None,
9-
InvalidOptions { message: String },
10-
PathNotFound { paths: Vec<PathBuf> },
11-
LintResult(LintResult),
12-
PrintConfigResult,
13-
ConfigFileInitResult { message: String },
14-
}
15-
16-
/// A summary of a complete linter run.
17-
#[derive(Debug, Default)]
18-
pub struct LintResult {
19-
/// The number of files that were linted.
20-
pub number_of_files: usize,
21-
/// The number of warnings that were found.
22-
pub number_of_warnings: usize,
23-
/// The number of errors that were found.
24-
pub number_of_errors: usize,
9+
InvalidOptions {
10+
message: String,
11+
},
12+
PathNotFound {
13+
paths: Vec<PathBuf>,
14+
},
2515
/// The exit unix code for, in general 0 or 1 (from `--deny-warnings` or `--max-warnings` for example)
26-
pub exit_code: ExitCode,
16+
LintResult(ExitCode),
17+
PrintConfigResult,
18+
ConfigFileInitResult {
19+
message: String,
20+
},
2721
}
2822

2923
impl Termination for CliRunResult {
@@ -39,12 +33,7 @@ impl Termination for CliRunResult {
3933
println!("Path {paths:?} does not exist.");
4034
ExitCode::from(1)
4135
}
42-
Self::LintResult(LintResult {
43-
number_of_files: _, // ToDo: only for tests, make snapshots
44-
number_of_warnings: _, // ToDo: only for tests, make snapshots
45-
number_of_errors: _,
46-
exit_code,
47-
}) => exit_code,
36+
Self::LintResult(exit_code) => exit_code,
4837
Self::ConfigFileInitResult { message } => {
4938
println!("{message}");
5039
ExitCode::from(0)

0 commit comments

Comments
 (0)
Please sign in to comment.