tidy extra checks that interact with --bless now all recommend using it
This commit is contained in:
parent
a9d884df81
commit
c19d81badb
1 changed files with 25 additions and 6 deletions
|
|
@ -124,6 +124,12 @@ fn check_impl(
|
|||
};
|
||||
}
|
||||
|
||||
let rerun_with_bless = |mode: &str, action: &str| {
|
||||
if !bless {
|
||||
eprintln!("rerun tidy with `--extra-checks={mode} --bless` to {action}");
|
||||
}
|
||||
};
|
||||
|
||||
let python_lint = extra_check!(Py, Lint);
|
||||
let python_fmt = extra_check!(Py, Fmt);
|
||||
let shell_lint = extra_check!(Shell, Lint);
|
||||
|
|
@ -158,10 +164,10 @@ fn check_impl(
|
|||
|
||||
let res = run_ruff(root_path, outdir, py_path, &cfg_args, &file_args, args);
|
||||
|
||||
if res.is_err() && show_diff {
|
||||
if res.is_err() && show_diff && !bless {
|
||||
eprintln!("\npython linting failed! Printing diff suggestions:");
|
||||
|
||||
let _ = run_ruff(
|
||||
let diff_res = run_ruff(
|
||||
root_path,
|
||||
outdir,
|
||||
py_path,
|
||||
|
|
@ -169,6 +175,10 @@ fn check_impl(
|
|||
&file_args,
|
||||
&["check".as_ref(), "--diff".as_ref()],
|
||||
);
|
||||
// `ruff check --diff` will return status 0 if there are no suggestions.
|
||||
if diff_res.is_err() {
|
||||
rerun_with_bless("py:lint", "apply ruff suggestions");
|
||||
}
|
||||
}
|
||||
// Rethrow error
|
||||
res?;
|
||||
|
|
@ -199,7 +209,7 @@ fn check_impl(
|
|||
&["format".as_ref(), "--diff".as_ref()],
|
||||
);
|
||||
}
|
||||
eprintln!("rerun tidy with `--extra-checks=py:fmt --bless` to reformat Python code");
|
||||
rerun_with_bless("py:fmt", "reformat Python code");
|
||||
}
|
||||
|
||||
// Rethrow error
|
||||
|
|
@ -232,7 +242,7 @@ fn check_impl(
|
|||
let args = merge_args(&cfg_args_clang_format, &file_args_clang_format);
|
||||
let res = py_runner(py_path.as_ref().unwrap(), false, None, "clang-format", &args);
|
||||
|
||||
if res.is_err() && show_diff {
|
||||
if res.is_err() && show_diff && !bless {
|
||||
eprintln!("\nclang-format linting failed! Printing diff suggestions:");
|
||||
|
||||
let mut cfg_args_clang_format_diff = cfg_args.clone();
|
||||
|
|
@ -272,6 +282,7 @@ fn check_impl(
|
|||
);
|
||||
}
|
||||
}
|
||||
rerun_with_bless("cpp:fmt", "reformat C++ code");
|
||||
}
|
||||
// Rethrow error
|
||||
res?;
|
||||
|
|
@ -302,7 +313,11 @@ fn check_impl(
|
|||
} else {
|
||||
eprintln!("spellchecking files");
|
||||
}
|
||||
spellcheck_runner(root_path, &outdir, &cargo, &args)?;
|
||||
let res = spellcheck_runner(root_path, &outdir, &cargo, &args);
|
||||
if res.is_err() {
|
||||
rerun_with_bless("spellcheck", "fix typos");
|
||||
}
|
||||
res?;
|
||||
}
|
||||
|
||||
if js_lint || js_typecheck {
|
||||
|
|
@ -315,7 +330,11 @@ fn check_impl(
|
|||
} else {
|
||||
eprintln!("linting javascript files and applying suggestions");
|
||||
}
|
||||
rustdoc_js::lint(outdir, librustdoc_path, tools_path, bless)?;
|
||||
let res = rustdoc_js::lint(outdir, librustdoc_path, tools_path, bless);
|
||||
if res.is_err() {
|
||||
rerun_with_bless("js:lint", "apply eslint suggestions");
|
||||
}
|
||||
res?;
|
||||
rustdoc_js::es_check(outdir, librustdoc_path)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue