diff --git a/INSTALL.md b/INSTALL.md index 4cead03036..013a099c95 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1 +1 @@ -See [doc/build-\*.md](/doc) \ No newline at end of file +See [doc/build-\*.md](/doc) diff --git a/doc/release-notes-31278.md b/doc/release-notes-31278.md index 1faa9577f5..82750dee0d 100644 --- a/doc/release-notes-31278.md +++ b/doc/release-notes-31278.md @@ -1,3 +1,3 @@ RPC and Startup Option --- -The `-paytxfee` startup option and the `settxfee` RPC are now deprecated and will be removed in Bitcoin Core 31.0. They allowed the user to set a static fee rate for wallet transactions, which could potentially lead to overpaying or underpaying. Users should instead rely on fee estimation or specify a fee rate per transaction using the `fee_rate` argument in RPCs such as `fundrawtransaction`, `sendtoaddress`, `send`, `sendall`, and `sendmany`. (#31278) \ No newline at end of file +The `-paytxfee` startup option and the `settxfee` RPC are now deprecated and will be removed in Bitcoin Core 31.0. They allowed the user to set a static fee rate for wallet transactions, which could potentially lead to overpaying or underpaying. Users should instead rely on fee estimation or specify a fee rate per transaction using the `fee_rate` argument in RPCs such as `fundrawtransaction`, `sendtoaddress`, `send`, `sendall`, and `sendmany`. (#31278) diff --git a/src/test/fuzz/bech32.cpp b/src/test/fuzz/bech32.cpp index 1937dd52fa..8c43bbbbd5 100644 --- a/src/test/fuzz/bech32.cpp +++ b/src/test/fuzz/bech32.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 The Bitcoin Core developers +// Copyright (c) 2019-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -66,4 +66,4 @@ FUZZ_TARGET(bech32_roundtrip) assert(decoded.data == converted_input); } } -} \ No newline at end of file +} diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs index dec43a7134..073e2dd44c 100644 --- a/test/lint/test_runner/src/main.rs +++ b/test/lint/test_runner/src/main.rs @@ -3,8 +3,8 @@ // file COPYING or https://opensource.org/license/mit/. use std::env; -use std::fs; -use std::io::ErrorKind; +use std::fs::{self, File}; +use std::io::{ErrorKind, Read, Seek, SeekFrom}; use std::path::PathBuf; use std::process::{Command, ExitCode, Stdio}; @@ -88,6 +88,11 @@ fn get_linter_list() -> Vec<&'static Linter> { name: "trailing_whitespace", lint_fn: lint_trailing_whitespace }, + &Linter { + description: "Check for trailing newline", + name: "trailing_newline", + lint_fn: lint_trailing_newline + }, &Linter { description: "Run all linters of the form: test/lint/lint-*.py", name: "all_python_linters", @@ -209,10 +214,13 @@ fn get_subtrees() -> Vec<&'static str> { ] } -/// Return the pathspecs to exclude all subtrees -fn get_pathspecs_exclude_subtrees() -> Vec { +/// Return the pathspecs to exclude by default +fn get_pathspecs_default_excludes() -> Vec { get_subtrees() .iter() + .chain(&[ + "doc/release-notes/release-notes-*", // archived notes + ]) .map(|s| format!(":(exclude){}", s)) .collect() } @@ -333,7 +341,7 @@ fn lint_py_lint() -> LintResult { let files = check_output( git() .args(["ls-files", "--", "*.py"]) - .args(get_pathspecs_exclude_subtrees()), + .args(get_pathspecs_default_excludes()), )?; let mut cmd = Command::new(bin_name); @@ -459,7 +467,7 @@ expected to follow the naming "/doc/release-notes-.md". /// Return the pathspecs for whitespace related excludes fn get_pathspecs_exclude_whitespace() -> Vec { - let mut list = get_pathspecs_exclude_subtrees(); + let mut list = get_pathspecs_default_excludes(); list.extend( [ // Permanent excludes @@ -468,7 +476,6 @@ fn get_pathspecs_exclude_whitespace() -> Vec { "contrib/windeploy/win-codesign.cert", "doc/README_windows.txt", // Temporary excludes, or existing violations - "doc/release-notes/release-notes-0.*", "contrib/init/bitcoind.openrc", "contrib/macdeploy/macdeployqtplus", "src/crypto/sha256_sse4.cpp", @@ -512,6 +519,44 @@ sourced files to the exclude list. } } +fn lint_trailing_newline() -> LintResult { + let files = check_output( + git() + .args([ + "ls-files", "--", "*.py", "*.cpp", "*.h", "*.md", "*.rs", "*.sh", "*.cmake", + ]) + .args(get_pathspecs_default_excludes()), + )?; + let mut missing_newline = false; + for path in files.lines() { + let mut file = File::open(path).expect("must be able to open file"); + if file.seek(SeekFrom::End(-1)).is_err() { + continue; // Allow fully empty files + } + let mut buffer = [0u8; 1]; + file.read_exact(&mut buffer) + .expect("must be able to read the last byte"); + if buffer[0] != b'\n' { + missing_newline = true; + println!("{path}"); + } + } + if missing_newline { + Err(r#" +A trailing newline is required, because git may warn about it missing. Also, it can make diffs +verbose and can break git blame after appending lines. + +Thus, it is best to add the trailing newline now. + +Please add any false positives to the exclude list. + "# + .trim() + .to_string()) + } else { + Ok(()) + } +} + fn lint_tabs_whitespace() -> LintResult { let tabs = git() .args(["grep", "-I", "--line-number", "--perl-regexp", "^\\t", "--"]) @@ -569,7 +614,7 @@ fn lint_includes_build_config() -> LintResult { "*.cpp", "*.h", ]) - .args(get_pathspecs_exclude_subtrees()) + .args(get_pathspecs_default_excludes()) .args([ // These are exceptions which don't use bitcoin-build-config.h, rather CMakeLists.txt adds // these cppflags manually.