Skip to content
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
27 changes: 27 additions & 0 deletions cpp-linter/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i32>,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

/// A struct to describe the CLI's source options.
Expand Down Expand Up @@ -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"]);
Expand Down
24 changes: 24 additions & 0 deletions cpp-linter/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ pub async fn run_main(args: Vec<String>) -> 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.");
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions docs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ fn generate_cli_doc(metadata: HashMap<String, HashMap<String, Py<PyAny>>>) -> 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()
Expand Down
Loading