Lintcheck: Add --warn-all
and make it the CI default
This commit is contained in:
parent
94a000b613
commit
25bb612538
4
.github/workflows/lintcheck.yml
vendored
4
.github/workflows/lintcheck.yml
vendored
@ -58,7 +58,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Run lintcheck
|
- name: Run lintcheck
|
||||||
if: steps.cache-json.outputs.cache-hit != 'true'
|
if: steps.cache-json.outputs.cache-hit != 'true'
|
||||||
run: ./target/debug/lintcheck --format json
|
run: ./target/debug/lintcheck --format json --warn-all
|
||||||
|
|
||||||
- name: Upload base JSON
|
- name: Upload base JSON
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@ -86,7 +86,7 @@ jobs:
|
|||||||
run: cargo build --manifest-path=lintcheck/Cargo.toml
|
run: cargo build --manifest-path=lintcheck/Cargo.toml
|
||||||
|
|
||||||
- name: Run lintcheck
|
- name: Run lintcheck
|
||||||
run: ./target/debug/lintcheck --format json
|
run: ./target/debug/lintcheck --format json --warn-all
|
||||||
|
|
||||||
- name: Upload head JSON
|
- name: Upload head JSON
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
@ -36,6 +36,10 @@ pub(crate) struct LintcheckConfig {
|
|||||||
/// Apply a filter to only collect specified lints, this also overrides `allow` attributes
|
/// Apply a filter to only collect specified lints, this also overrides `allow` attributes
|
||||||
#[clap(long = "filter", value_name = "clippy_lint_name", use_value_delimiter = true)]
|
#[clap(long = "filter", value_name = "clippy_lint_name", use_value_delimiter = true)]
|
||||||
pub lint_filter: Vec<String>,
|
pub lint_filter: Vec<String>,
|
||||||
|
/// Set all lints to the "warn" lint level, even resitriction ones. Usually,
|
||||||
|
/// it's better to use `--filter` instead
|
||||||
|
#[clap(long, conflicts_with("lint_filter"))]
|
||||||
|
pub warn_all: bool,
|
||||||
/// Set the output format of the log file
|
/// Set the output format of the log file
|
||||||
#[clap(long, short, default_value = "text")]
|
#[clap(long, short, default_value = "text")]
|
||||||
pub format: OutputFormat,
|
pub format: OutputFormat,
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// When a new lint is introduced, we can search the results for new warnings and check for false
|
// When a new lint is introduced, we can search the results for new warnings and check for false
|
||||||
// positives.
|
// positives.
|
||||||
|
|
||||||
|
#![feature(iter_collect_into)]
|
||||||
#![warn(
|
#![warn(
|
||||||
trivial_casts,
|
trivial_casts,
|
||||||
trivial_numeric_casts,
|
trivial_numeric_casts,
|
||||||
@ -352,7 +353,7 @@ impl Crate {
|
|||||||
target_dir_index: &AtomicUsize,
|
target_dir_index: &AtomicUsize,
|
||||||
total_crates_to_lint: usize,
|
total_crates_to_lint: usize,
|
||||||
config: &LintcheckConfig,
|
config: &LintcheckConfig,
|
||||||
lint_filter: &[String],
|
lint_levels_args: &[String],
|
||||||
server: &Option<LintcheckServer>,
|
server: &Option<LintcheckServer>,
|
||||||
) -> Vec<ClippyCheckOutput> {
|
) -> Vec<ClippyCheckOutput> {
|
||||||
// advance the atomic index by one
|
// advance the atomic index by one
|
||||||
@ -398,16 +399,9 @@ impl Crate {
|
|||||||
for opt in options {
|
for opt in options {
|
||||||
clippy_args.push(opt);
|
clippy_args.push(opt);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
clippy_args.extend(["-Wclippy::pedantic", "-Wclippy::cargo"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if lint_filter.is_empty() {
|
clippy_args.extend(lint_levels_args.iter().map(String::as_str));
|
||||||
clippy_args.push("--cap-lints=warn");
|
|
||||||
} else {
|
|
||||||
clippy_args.push("--cap-lints=allow");
|
|
||||||
clippy_args.extend(lint_filter.iter().map(String::as_str));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut cmd = Command::new("cargo");
|
let mut cmd = Command::new("cargo");
|
||||||
cmd.arg(if config.fix { "fix" } else { "check" })
|
cmd.arg(if config.fix { "fix" } else { "check" })
|
||||||
@ -638,15 +632,39 @@ fn lintcheck(config: LintcheckConfig) {
|
|||||||
let (crates, recursive_options) = read_crates(&config.sources_toml_path);
|
let (crates, recursive_options) = read_crates(&config.sources_toml_path);
|
||||||
|
|
||||||
let counter = AtomicUsize::new(1);
|
let counter = AtomicUsize::new(1);
|
||||||
let lint_filter: Vec<String> = config
|
let mut lint_level_args: Vec<String> = vec![];
|
||||||
.lint_filter
|
if config.lint_filter.is_empty() {
|
||||||
.iter()
|
lint_level_args.push("--cap-lints=warn".to_string());
|
||||||
.map(|filter| {
|
|
||||||
let mut filter = filter.clone();
|
// Set allow-by-default to warn
|
||||||
filter.insert_str(0, "--force-warn=");
|
if config.warn_all {
|
||||||
filter
|
[
|
||||||
})
|
"clippy::cargo",
|
||||||
.collect();
|
"clippy::nursery",
|
||||||
|
"clippy::pedantic",
|
||||||
|
"clippy::restriction",
|
||||||
|
]
|
||||||
|
.iter()
|
||||||
|
.map(|group| format!("--warn={group}"))
|
||||||
|
.collect_into(&mut lint_level_args);
|
||||||
|
} else {
|
||||||
|
["clippy::cargo", "clippy::pedantic"]
|
||||||
|
.iter()
|
||||||
|
.map(|group| format!("--warn={group}"))
|
||||||
|
.collect_into(&mut lint_level_args);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lint_level_args.push("--cap-lints=allow".to_string());
|
||||||
|
config
|
||||||
|
.lint_filter
|
||||||
|
.iter()
|
||||||
|
.map(|filter| {
|
||||||
|
let mut filter = filter.clone();
|
||||||
|
filter.insert_str(0, "--force-warn=");
|
||||||
|
filter
|
||||||
|
})
|
||||||
|
.collect_into(&mut lint_level_args);
|
||||||
|
};
|
||||||
|
|
||||||
let crates: Vec<Crate> = crates
|
let crates: Vec<Crate> = crates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -698,7 +716,7 @@ fn lintcheck(config: LintcheckConfig) {
|
|||||||
&counter,
|
&counter,
|
||||||
crates.len(),
|
crates.len(),
|
||||||
&config,
|
&config,
|
||||||
&lint_filter,
|
&lint_level_args,
|
||||||
&server,
|
&server,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user