Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lintcheck: force warn all lints #13210

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lintcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:

- name: Run lintcheck
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
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
run: cargo build --manifest-path=lintcheck/Cargo.toml

- 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
uses: actions/upload-artifact@v4
Expand Down
8 changes: 4 additions & 4 deletions lintcheck/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub(crate) struct LintcheckConfig {
/// Runs cargo clippy --fix and checks if all suggestions apply
#[clap(long, conflicts_with("max_jobs"))]
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)]
pub lint_filter: Vec<String>,
/// Set all lints to the "warn" lint level, even resitriction ones. Usually,
/// it's better to use `--filter` instead
/// Check all Clippy lints, by default only `clippy::all` and `clippy::pedantic` are checked.
/// Usually, it's better to use `--filter` instead
#[clap(long, conflicts_with("lint_filter"))]
pub warn_all: bool,
pub all_lints: bool,
/// Set the output format of the log file
#[clap(long, short, default_value = "text")]
pub format: OutputFormat,
Expand Down
25 changes: 10 additions & 15 deletions lintcheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,24 @@ fn lintcheck(config: LintcheckConfig) {
let (crates, recursive_options) = read_crates(&config.sources_toml_path);

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() {
lint_level_args.push("--cap-lints=warn".to_string());

// Set allow-by-default to warn
if config.warn_all {
[
let groups = if config.all_lints {
&[
"clippy::all",
"clippy::cargo",
"clippy::nursery",
"clippy::pedantic",
"clippy::restriction",
]
][..]
} else {
&["clippy::all", "clippy::pedantic"]
};
groups
.iter()
.map(|group| format!("--warn={group}"))
.map(|group| format!("--force-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()
Expand Down