diff --git a/cpp-linter/src/cli/mod.rs b/cpp-linter/src/cli/mod.rs index ef7e52e6..10a5ad78 100644 --- a/cpp-linter/src/cli/mod.rs +++ b/cpp-linter/src/cli/mod.rs @@ -168,6 +168,22 @@ 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. 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, + overrides_with = "jobs" + )] + pub jobs: Option, } /// A struct to describe the CLI's source options. @@ -681,6 +697,17 @@ 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()); + let args = Cli::parse_from(vec!["cpp-linter", "-j", "1", "--jobs", "4"]); + assert_eq!(args.general_options.jobs, Some(4)); + } + #[test] fn extra_arg_0() { let args = Cli::parse_from(vec!["cpp-linter"]); 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()