lint(clippy): warn on manual printing to stdout or stderr (#3767)
Most logging should use `tracing::trace!()` or `tracing::debug!()` instead.
This commit is contained in:
parent
cee770fe2c
commit
cef146edbd
|
|
@ -38,6 +38,12 @@ rustflags = [
|
||||||
"-Wclippy::dbg_macro",
|
"-Wclippy::dbg_macro",
|
||||||
"-Wclippy::todo",
|
"-Wclippy::todo",
|
||||||
|
|
||||||
|
# Manual debugging output.
|
||||||
|
# Use tracing::trace!() or tracing::debug!() instead.
|
||||||
|
"-Wclippy::print_stdout",
|
||||||
|
"-Wclippy::print_stderr",
|
||||||
|
"-Wclippy::dbg_macro",
|
||||||
|
|
||||||
# Code styles we want to accept
|
# Code styles we want to accept
|
||||||
"-Aclippy::try_err",
|
"-Aclippy::try_err",
|
||||||
|
|
||||||
|
|
@ -59,10 +65,6 @@ rustflags = [
|
||||||
#"-Wclippy::cast_precision_loss", # 25 non-test warnings, 10 test warnings
|
#"-Wclippy::cast_precision_loss", # 25 non-test warnings, 10 test warnings
|
||||||
#"-Wclippy::cast_sign_loss", # 6 non-test warnings, 15 test warnings
|
#"-Wclippy::cast_sign_loss", # 6 non-test warnings, 15 test warnings
|
||||||
|
|
||||||
# disable these lints using a zebra-test config.toml, but warn for other crates
|
|
||||||
#"-Wclippy::print_stdout",
|
|
||||||
#"-Wclippy::print_stderr",
|
|
||||||
|
|
||||||
# fix hidden lifetime parameters
|
# fix hidden lifetime parameters
|
||||||
#"-Wrust_2018_idioms",
|
#"-Wrust_2018_idioms",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,6 @@ use NetworkUpgrade::*;
|
||||||
fn activation_bijective() {
|
fn activation_bijective() {
|
||||||
zebra_test::init();
|
zebra_test::init();
|
||||||
|
|
||||||
if std::env::var_os("TEST_FAKE_ACTIVATION_HEIGHTS").is_some() {
|
|
||||||
eprintln!("Skipping activation_bijective() since $TEST_FAKE_ACTIVATION_HEIGHTS is set");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mainnet_activations = NetworkUpgrade::activation_list(Mainnet);
|
let mainnet_activations = NetworkUpgrade::activation_list(Mainnet);
|
||||||
let mainnet_heights: HashSet<&block::Height> = mainnet_activations.keys().collect();
|
let mainnet_heights: HashSet<&block::Height> = mainnet_activations.keys().collect();
|
||||||
assert_eq!(MAINNET_ACTIVATION_HEIGHTS.len(), mainnet_heights.len());
|
assert_eq!(MAINNET_ACTIVATION_HEIGHTS.len(), mainnet_heights.len());
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// Modified from:
|
// Modified from:
|
||||||
// https://github.com/zcash/librustzcash/blob/c48bb4def2e122289843ddb3cb2984c325c03ca0/zcash_proofs/examples/get-params-path.rs
|
// https://github.com/zcash/librustzcash/blob/c48bb4def2e122289843ddb3cb2984c325c03ca0/zcash_proofs/examples/get-params-path.rs
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let path = zebra_consensus::groth16::Groth16Parameters::directory();
|
let path = zebra_consensus::groth16::Groth16Parameters::directory();
|
||||||
if let Some(path) = path.to_str() {
|
if let Some(path) = path.to_str() {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ use zebra_chain::{
|
||||||
|
|
||||||
use crate::primitives::halo2::*;
|
use crate::primitives::halo2::*;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code, clippy::print_stdout)]
|
||||||
fn generate_test_vectors() {
|
fn generate_test_vectors() {
|
||||||
let proving_key = ProvingKey::build();
|
let proving_key = ProvingKey::build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ fn blocks_with_v5_transactions() -> Result<()> {
|
||||||
///
|
///
|
||||||
/// This test requires setting the TEST_FAKE_ACTIVATION_HEIGHTS.
|
/// This test requires setting the TEST_FAKE_ACTIVATION_HEIGHTS.
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn all_upgrades_and_wrong_commitments_with_fake_activation_heights() -> Result<()> {
|
fn all_upgrades_and_wrong_commitments_with_fake_activation_heights() -> Result<()> {
|
||||||
zebra_test::init();
|
zebra_test::init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,7 @@ impl<T> TestChild<T> {
|
||||||
/// Note: the timeout is only checked after each full line is received from
|
/// Note: the timeout is only checked after each full line is received from
|
||||||
/// the child.
|
/// the child.
|
||||||
#[instrument(skip(self, lines))]
|
#[instrument(skip(self, lines))]
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
pub fn expect_line_matching<L>(
|
pub fn expect_line_matching<L>(
|
||||||
&mut self,
|
&mut self,
|
||||||
lines: &mut L,
|
lines: &mut L,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ const ZEBRA_SKIP_IPV6_TESTS: &str = "ZEBRA_SKIP_IPV6_TESTS";
|
||||||
/// Should we skip Zebra tests which need reliable, fast network connectivity?
|
/// Should we skip Zebra tests which need reliable, fast network connectivity?
|
||||||
//
|
//
|
||||||
// TODO: separate "good and reliable" from "any network"?
|
// TODO: separate "good and reliable" from "any network"?
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
pub fn zebra_skip_network_tests() -> bool {
|
pub fn zebra_skip_network_tests() -> bool {
|
||||||
if env::var_os(ZEBRA_SKIP_NETWORK_TESTS).is_some() {
|
if env::var_os(ZEBRA_SKIP_NETWORK_TESTS).is_some() {
|
||||||
// This message is captured by the test runner, use
|
// This message is captured by the test runner, use
|
||||||
|
|
@ -34,6 +35,7 @@ pub fn zebra_skip_network_tests() -> bool {
|
||||||
///
|
///
|
||||||
/// Since `zebra_skip_network_tests` only disables tests which need reliable network connectivity,
|
/// Since `zebra_skip_network_tests` only disables tests which need reliable network connectivity,
|
||||||
/// we allow IPv6 tests even when `ZEBRA_SKIP_NETWORK_TESTS` is set.
|
/// we allow IPv6 tests even when `ZEBRA_SKIP_NETWORK_TESTS` is set.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
pub fn zebra_skip_ipv6_tests() -> bool {
|
pub fn zebra_skip_ipv6_tests() -> bool {
|
||||||
if env::var_os(ZEBRA_SKIP_IPV6_TESTS).is_some() {
|
if env::var_os(ZEBRA_SKIP_IPV6_TESTS).is_some() {
|
||||||
eprintln!("Skipping IPv6 network test because '$ZEBRA_SKIP_IPV6_TESTS' is set.");
|
eprintln!("Skipping IPv6 network test because '$ZEBRA_SKIP_IPV6_TESTS' is set.");
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use zebra_test::{command::TestDirExt, prelude::Stdio};
|
||||||
/// (This message is captured by the test runner, use `cargo test -- --nocapture` to see it.)
|
/// (This message is captured by the test runner, use `cargo test -- --nocapture` to see it.)
|
||||||
///
|
///
|
||||||
/// The command's stdout and stderr are ignored.
|
/// The command's stdout and stderr are ignored.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn is_command_available(cmd: &str, args: &[&str]) -> bool {
|
fn is_command_available(cmd: &str, args: &[&str]) -> bool {
|
||||||
let status = Command::new(cmd)
|
let status = Command::new(cmd)
|
||||||
.args(args)
|
.args(args)
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ fn cmd_output(cmd: &mut std::process::Command) -> Result<String> {
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
init_tracing();
|
init_tracing();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ fn disable_non_reproducible(_config: &mut Config) {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
disable_non_reproducible(&mut config);
|
disable_non_reproducible(&mut config);
|
||||||
|
|
@ -48,7 +49,7 @@ fn main() {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"git error in vergen build script: skipping git env vars: {:?}",
|
"git error in vergen build script: skipping git env vars: {:?}",
|
||||||
e
|
e,
|
||||||
);
|
);
|
||||||
*config.git_mut().enabled_mut() = false;
|
*config.git_mut().enabled_mut() = false;
|
||||||
vergen(config).expect("non-git vergen should succeed");
|
vergen(config).expect("non-git vergen should succeed");
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,7 @@ impl Application for ZebradApp {
|
||||||
/// If you would like to add additional components to your application
|
/// If you would like to add additional components to your application
|
||||||
/// beyond the default ones provided by the framework, this is the place
|
/// beyond the default ones provided by the framework, this is the place
|
||||||
/// to do so.
|
/// to do so.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> {
|
fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> {
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
metrics::MetricsEndpoint, tokio::TokioComponent, tracing::TracingEndpoint,
|
metrics::MetricsEndpoint, tokio::TokioComponent, tracing::TracingEndpoint,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ pub struct GenerateCmd {
|
||||||
|
|
||||||
impl Runnable for GenerateCmd {
|
impl Runnable for GenerateCmd {
|
||||||
/// Start the application.
|
/// Start the application.
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
fn run(&self) {
|
fn run(&self) {
|
||||||
let default_config = ZebradConfig::default();
|
let default_config = ZebradConfig::default();
|
||||||
let mut output = r"# Default configuration for zebrad.
|
let mut output = r"# Default configuration for zebrad.
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ pub struct VersionCmd {}
|
||||||
|
|
||||||
impl Runnable for VersionCmd {
|
impl Runnable for VersionCmd {
|
||||||
/// Print version message
|
/// Print version message
|
||||||
|
#[allow(clippy::print_stdout)]
|
||||||
fn run(&self) {
|
fn run(&self) {
|
||||||
println!("{} {}", ZebradCmd::name(), ZebradCmd::version());
|
println!("{} {}", ZebradCmd::name(), ZebradCmd::version());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1261,6 +1261,7 @@ fn cached_mandatory_checkpoint_test_config() -> Result<ZebradConfig> {
|
||||||
///
|
///
|
||||||
/// Returns an error if the child exits or the fixed timeout elapses
|
/// Returns an error if the child exits or the fixed timeout elapses
|
||||||
/// before `STOP_AT_HEIGHT_REGEX` is found.
|
/// before `STOP_AT_HEIGHT_REGEX` is found.
|
||||||
|
#[allow(clippy::print_stderr)]
|
||||||
fn create_cached_database_height(
|
fn create_cached_database_height(
|
||||||
network: Network,
|
network: Network,
|
||||||
height: Height,
|
height: Height,
|
||||||
|
|
@ -1268,7 +1269,8 @@ fn create_cached_database_height(
|
||||||
checkpoint_sync: bool,
|
checkpoint_sync: bool,
|
||||||
stop_regex: &str,
|
stop_regex: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
println!("Creating cached database");
|
eprintln!("creating cached database");
|
||||||
|
|
||||||
// 16 hours
|
// 16 hours
|
||||||
let timeout = Duration::from_secs(60 * 60 * 16);
|
let timeout = Duration::from_secs(60 * 60 * 16);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue