mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Auto merge of #13210 - Alexendoo:lintcheck-force-warn, r=xFrednet
lintcheck: force warn all lints It occurred to me that like `--filter` we could use `--force-warn` for normal operations, we especially want to see lints that crates decided were too annoying or were false positives Also excludes `clippy::cargo` from the default set as nobody is really writing those and it slows things down r? `@xFrednet` changelog: none
This commit is contained in:
commit
a411267453
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 --warn-all --crates-toml ./lintcheck/ci_crates.toml
|
run: ./target/debug/lintcheck --format json --all-lints --crates-toml ./lintcheck/ci_crates.toml
|
||||||
|
|
||||||
- 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 --warn-all --crates-toml ./lintcheck/ci_crates.toml
|
run: ./target/debug/lintcheck --format json --all-lints --crates-toml ./lintcheck/ci_crates.toml
|
||||||
|
|
||||||
- name: Upload head JSON
|
- name: Upload head JSON
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
@ -33,13 +33,13 @@ pub(crate) struct LintcheckConfig {
|
|||||||
/// Runs cargo clippy --fix and checks if all suggestions apply
|
/// Runs cargo clippy --fix and checks if all suggestions apply
|
||||||
#[clap(long, conflicts_with("max_jobs"))]
|
#[clap(long, conflicts_with("max_jobs"))]
|
||||||
pub fix: bool,
|
pub fix: bool,
|
||||||
/// Apply a filter to only collect specified lints, this also overrides `allow` attributes
|
/// Apply a filter to only collect specified lints
|
||||||
#[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,
|
/// Check all Clippy lints, by default only `clippy::all` and `clippy::pedantic` are checked.
|
||||||
/// it's better to use `--filter` instead
|
/// Usually, it's better to use `--filter` instead
|
||||||
#[clap(long, conflicts_with("lint_filter"))]
|
#[clap(long, conflicts_with("lint_filter"))]
|
||||||
pub warn_all: bool,
|
pub all_lints: 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,
|
||||||
|
@ -284,29 +284,24 @@ 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 mut lint_level_args: Vec<String> = vec![];
|
let mut lint_level_args: Vec<String> = vec!["--cap-lints=allow".into()];
|
||||||
if config.lint_filter.is_empty() {
|
if config.lint_filter.is_empty() {
|
||||||
lint_level_args.push("--cap-lints=warn".to_string());
|
let groups = if config.all_lints {
|
||||||
|
&[
|
||||||
// Set allow-by-default to warn
|
"clippy::all",
|
||||||
if config.warn_all {
|
|
||||||
[
|
|
||||||
"clippy::cargo",
|
"clippy::cargo",
|
||||||
"clippy::nursery",
|
"clippy::nursery",
|
||||||
"clippy::pedantic",
|
"clippy::pedantic",
|
||||||
"clippy::restriction",
|
"clippy::restriction",
|
||||||
]
|
][..]
|
||||||
.iter()
|
|
||||||
.map(|group| format!("--warn={group}"))
|
|
||||||
.collect_into(&mut lint_level_args);
|
|
||||||
} else {
|
} else {
|
||||||
["clippy::cargo", "clippy::pedantic"]
|
&["clippy::all", "clippy::pedantic"]
|
||||||
.iter()
|
};
|
||||||
.map(|group| format!("--warn={group}"))
|
groups
|
||||||
.collect_into(&mut lint_level_args);
|
.iter()
|
||||||
}
|
.map(|group| format!("--force-warn={group}"))
|
||||||
|
.collect_into(&mut lint_level_args);
|
||||||
} else {
|
} else {
|
||||||
lint_level_args.push("--cap-lints=allow".to_string());
|
|
||||||
config
|
config
|
||||||
.lint_filter
|
.lint_filter
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user