From ca73ef720d92759bedcd5a0c31379e62beba3ab2 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:11:51 +0000 Subject: [PATCH 1/3] feat: accept and ignore v1's `--jobs` with a deprecation warning --- cpp-linter/src/cli/mod.rs | 8 ++++++++ cpp-linter/src/run.rs | 24 ++++++++++++++++++++++++ docs/src/lib.rs | 3 +++ 3 files changed, 35 insertions(+) diff --git a/cpp-linter/src/cli/mod.rs b/cpp-linter/src/cli/mod.rs index ef7e52e6..fac06640 100644 --- a/cpp-linter/src/cli/mod.rs +++ b/cpp-linter/src/cli/mod.rs @@ -168,6 +168,14 @@ pub struct GeneralOptions { conflicts_with = "mod_sys", )] pub no_mod_sys: bool, + + /// Deprecated and ignored. + /// + /// cpp-linter v1 used this to set the number of parallel jobs. + /// v2 always analyzes files in parallel, so a given value only + /// causes a deprecation warning. + #[arg(short = 'j', long, value_name = "JOBS", hide = true)] + pub jobs: Option, } /// A struct to describe the CLI's source options. diff --git a/cpp-linter/src/run.rs b/cpp-linter/src/run.rs index 6f971372..42d9981d 100644 --- a/cpp-linter/src/run.rs +++ b/cpp-linter/src/run.rs @@ -72,6 +72,11 @@ pub async fn run_main(args: Vec) -> Result<()> { LevelFilter::Info }, ); + if cli.general_options.jobs.is_some() { + log::warn!( + "The `--jobs` option is deprecated and ignored. Files are always analyzed in parallel." + ); + } let is_pr = rest_api_client.is_pr(); if !is_pr && cli.feedback_options.pr_review && rest_api_client.client_kind() == "local" { log::warn!("Pull request reviews are only posted when running in a supported CI platform."); @@ -373,6 +378,25 @@ pub(crate) mod test { drop(tmp_gh_out); } + // v1's `--jobs` is accepted and ignored (with a warning) instead of failing to parse. + #[tokio::test] + async fn deprecated_jobs() { + let tmp_gh_out = setup_tmp_gh_out_path(); + run_main(vec![ + "cpp-linter".to_string(), + "-l".to_string(), + "false".to_string(), + "--style".to_string(), + String::new(), + "--tidy-checks=-*".to_string(), + "-j".to_string(), + "2".to_string(), + ]) + .await + .unwrap(); + drop(tmp_gh_out); + } + #[tokio::test] async fn only_not_ignored() { let tmp_gh_out = setup_tmp_gh_out_path(); diff --git a/docs/src/lib.rs b/docs/src/lib.rs index f75f9fbc..1a82470d 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -80,6 +80,9 @@ fn generate_cli_doc(metadata: HashMap>>) -> Py arg_id.as_str(), group.get_id().as_str() )))?; + if arg.is_hide_set() { + continue; + } let long_name = arg.get_long().ok_or(PyValueError::new_err(format!( "Failed to get long name of argument with id {}", arg_id.as_str() From d2dcf73c869553461d57824eedfcb1aa88a70cb2 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:59:24 +0000 Subject: [PATCH 2/3] fix: parse the deprecated `--jobs` value as an integer like v1 --- cpp-linter/src/cli/mod.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cpp-linter/src/cli/mod.rs b/cpp-linter/src/cli/mod.rs index fac06640..a082fbb7 100644 --- a/cpp-linter/src/cli/mod.rs +++ b/cpp-linter/src/cli/mod.rs @@ -173,9 +173,16 @@ pub struct GeneralOptions { /// /// cpp-linter v1 used this to set the number of parallel jobs. /// v2 always analyzes files in parallel, so a given value only - /// causes a deprecation warning. - #[arg(short = 'j', long, value_name = "JOBS", hide = true)] - pub jobs: Option, + /// causes a deprecation warning. Like v1, the value must be an integer + /// (v1 treated zero or a negative value as "use all CPUs"). + #[arg( + short = 'j', + long, + value_name = "JOBS", + hide = true, + allow_negative_numbers = true + )] + pub jobs: Option, } /// A struct to describe the CLI's source options. @@ -689,6 +696,15 @@ mod test { assert!(Cli::try_parse_from(vec!["cpp-linter", "--mod-sys", "--no-mod-sys"]).is_err()); } + #[test] + fn deprecated_jobs_takes_an_integer() { + let args = Cli::parse_from(vec!["cpp-linter", "-j", "4"]); + assert_eq!(args.general_options.jobs, Some(4)); + let args = Cli::parse_from(vec!["cpp-linter", "--jobs", "-1"]); + assert_eq!(args.general_options.jobs, Some(-1)); + assert!(Cli::try_parse_from(vec!["cpp-linter", "-j", "nope"]).is_err()); + } + #[test] fn extra_arg_0() { let args = Cli::parse_from(vec!["cpp-linter"]); From 9bc155e661c803d99af47a11c314a873513e1a0a Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:03:56 +0000 Subject: [PATCH 3/3] fix: let a repeated `--jobs` override the earlier one --- cpp-linter/src/cli/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpp-linter/src/cli/mod.rs b/cpp-linter/src/cli/mod.rs index a082fbb7..10a5ad78 100644 --- a/cpp-linter/src/cli/mod.rs +++ b/cpp-linter/src/cli/mod.rs @@ -180,7 +180,8 @@ pub struct GeneralOptions { long, value_name = "JOBS", hide = true, - allow_negative_numbers = true + allow_negative_numbers = true, + overrides_with = "jobs" )] pub jobs: Option, } @@ -703,6 +704,8 @@ mod test { let args = Cli::parse_from(vec!["cpp-linter", "--jobs", "-1"]); assert_eq!(args.general_options.jobs, Some(-1)); assert!(Cli::try_parse_from(vec!["cpp-linter", "-j", "nope"]).is_err()); + let args = Cli::parse_from(vec!["cpp-linter", "-j", "1", "--jobs", "4"]); + assert_eq!(args.general_options.jobs, Some(4)); } #[test]