Merge bitcoin/bitcoin#34976: lint: Clarify rmtree/remove_all error message with preferred alternatives

fa955af618 lint: Clarify rmtree/remove_all error message with preferred alternatives (MarcoFalke)

Pull request description:

  An error message without a suggestion to fix will often lead developers to come up with a creative solution to side-step the grep in the linter (such as using an `auto` alias or other style-change).

  Try to avoid this by mentioning a recommended solution.

ACKs for top commit:
  davidgumberg:
    ACK fa955af618
  achow101:
    ACK fa955af618
  hodlinator:
    ACK fa955af618

Tree-SHA512: d5741b2fdb1cfcffc26144c3bb78478e46d7ecb5c3340cbb09584fe1274a3cc8c6872b997e33b8bd2097630d916133a3f5bf41a1d09527e597be9829d6d3e51b
This commit is contained in:
Ava Chow
2026-04-01 13:28:42 -07:00
3 changed files with 6 additions and 4 deletions

View File

@@ -139,7 +139,8 @@ pub fn lint_remove_all() -> LintResult {
.success();
if found {
Err(r#"
Use of fs::remove_all or std::filesystem::remove_all is dangerous and should be avoided.
Use of fs::remove_all or std::filesystem::remove_all is dangerous and should be avoided. If removal
is required, prefer fs::remove.
"#
.trim()
.to_string())

View File

@@ -89,7 +89,8 @@ pub fn lint_rmtree() -> LintResult {
.success();
if found {
Err(r#"
Use of shutil.rmtree() is dangerous and should be avoided.
Use of shutil.rmtree() is dangerous and should be avoided. If it
is really required for the test, use self.cleanup_folder(_).
"#
.trim()
.to_string())
@@ -97,4 +98,3 @@ Use of shutil.rmtree() is dangerous and should be avoided.
Ok(())
}
}

View File

@@ -14,7 +14,8 @@ use std::fs;
use std::process::{Command, ExitCode};
use lint_cpp::{
lint_boost_assert, lint_includes_build_config, lint_remove_all, lint_rpc_assert, lint_std_filesystem,
lint_boost_assert, lint_includes_build_config, lint_remove_all, lint_rpc_assert,
lint_std_filesystem,
};
use lint_docs::{lint_doc_args, lint_doc_release_note_snippets, lint_markdown};
use lint_py::{lint_py_lint, lint_rmtree};