lint: [move-only] Move repo related lints to lint_repo_hygiene.rs
What changed, and why it matters
This commit is a simple housekeeping change: it moves two existing code-checking helper functions into a new file and runs a code formatter on another file. There is no change to Bitcoin's actual behavior, no bug fix, and no security relevance.
No action needed; this is a non-security refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure refactor of the lint test runner. Two functions, lint_subtree() and lint_scripted_diff(), are relocated from test/lint/test_runner/src/main.rs to a new module test/lint/test_runner/src/lint_repo_hygiene.rs. main.rs is updated to import and use the new module, and cargo fmt is applied, producing only whitespace/formatting changes. No logic is modified.
Changed components
test/lint/test_runner/src/main.rstest/lint/test_runner/src/lint_repo_hygiene.rsInspect captured patch +43 / −36
diff --git a/test/lint/test_runner/src/lint_repo_hygiene.rs b/test/lint/test_runner/src/lint_repo_hygiene.rs
new file mode 100644
index 00000000..d2fc0791
--- /dev/null
+++ b/test/lint/test_runner/src/lint_repo_hygiene.rs
@@ -0,0 +1,38 @@
+// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or https://opensource.org/license/mit/.
+
+use std::process::Command;
+
+use crate::util::{commit_range, get_subtrees, LintResult};
+
+pub fn lint_subtree() -> LintResult {
+ // This only checks that the trees are pure subtrees, it is not doing a full
+ // check with -r to not have to fetch all the remotes.
+ let mut good = true;
+ for subtree in get_subtrees() {
+ good &= Command::new("test/lint/git-subtree-check.sh")
+ .arg(subtree)
+ .status()
+ .expect("command_error")
+ .success();
+ }
+ if good {
+ Ok(())
+ } else {
+ Err("".to_string())
+ }
+}
+
+pub fn lint_scripted_diff() -> LintResult {
+ if Command::new("test/lint/commit-script-check.sh")
+ .arg(commit_range())
+ .status()
+ .expect("command error")
+ .success()
+ {
+ Ok(())
+ } else {
+ Err("".to_string())
+ }
+}
diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs
index eddbff9d..ba774238 100644
--- a/test/lint/test_runner/src/main.rs
+++ b/test/lint/test_runner/src/main.rs
@@ -4,6 +4,7 @@
mod lint_cpp;
mod lint_docs;
+mod lint_repo_hygiene;
mod lint_text_format;
mod util;
@@ -16,12 +17,13 @@ use lint_cpp::{
lint_boost_assert, lint_includes_build_config, lint_rpc_assert, lint_std_filesystem,
};
use lint_docs::{lint_doc_args, lint_doc_release_note_snippets, lint_markdown};
+use lint_repo_hygiene::{lint_scripted_diff, lint_subtree};
use lint_text_format::{
lint_commit_msg, lint_tabs_whitespace, lint_trailing_newline, lint_trailing_whitespace,
};
use util::{
- check_output, commit_range, get_git_root, get_pathspecs_default_excludes, get_subtrees, git,
- LintFn, LintResult,
+ check_output, commit_range, get_git_root, get_pathspecs_default_excludes, git, LintFn,
+ LintResult,
};
struct Linter {
@@ -166,37 +168,6 @@ fn parse_lint_args(args: &[String]) -> Vec<&'static Linter> {
lint_values
}
-fn lint_subtree() -> LintResult {
- // This only checks that the trees are pure subtrees, it is not doing a full
- // check with -r to not have to fetch all the remotes.
- let mut good = true;
- for subtree in get_subtrees() {
- good &= Command::new("test/lint/git-subtree-check.sh")
- .arg(subtree)
- .status()
- .expect("command_error")
- .success();
- }
- if good {
- Ok(())
- } else {
- Err("".to_string())
- }
-}
-
-fn lint_scripted_diff() -> LintResult {
- if Command::new("test/lint/commit-script-check.sh")
- .arg(commit_range())
- .status()
- .expect("command error")
- .success()
- {
- Ok(())
- } else {
- Err("".to_string())
- }
-}
-
fn lint_py_lint() -> LintResult {
let bin_name = "ruff";
let checks = format!(
@@ -257,9 +228,7 @@ fn lint_py_lint() -> LintResult {
Ok(status) if status.success() => Ok(()),
Ok(_) => Err(format!("`{bin_name}` found errors!")),
Err(e) if e.kind() == ErrorKind::NotFound => {
- println!(
- "`{bin_name}` was not found in $PATH, skipping those checks."
- );
+ println!("`{bin_name}` was not found in $PATH, skipping those checks.");
Ok(())
}
Err(e) => Err(format!("Error running `{bin_name}`: {e}")),
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.