From 43446b3a71583d93b2fecb0be6c0df0641263c43 Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Thu, 8 Oct 2026 12:54:12 -0400 Subject: [PATCH 1/2] chore(config): Enable pedantic lints for graph and builders --- src/config/api.rs | 14 ++++++++ src/config/builder.rs | 35 ++++++++++++++++++-- src/config/compiler.rs | 41 +++++++++++++++-------- src/config/component.rs | 4 +++ src/config/diff.rs | 19 +++++++++-- src/config/enrichment_table.rs | 16 ++++++++- src/config/format.rs | 28 ++++++++++++++-- src/config/graph.rs | 14 ++++---- src/config/graph_builder.rs | 7 ++++ src/config/mod.rs | 59 +++++++++++++++++++++++++++------- 10 files changed, 196 insertions(+), 41 deletions(-) diff --git a/src/config/api.rs b/src/config/api.rs index bffe99bff0071..0ad416614d849 100644 --- a/src/config/api.rs +++ b/src/config/api.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use std::net::{Ipv4Addr, SocketAddr}; use url::Url; @@ -44,11 +46,18 @@ const fn default_enabled() -> bool { /// By default, the API binds to 127.0.0.1:8686. This function should remain public; /// `vector top` will use it to determine which to connect to by default, if no URL /// override is provided. +#[must_use] pub fn default_address() -> Option { Some(SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 8686)) } /// Default gRPC API address for `vector top` and other API clients +#[must_use] +// https://github.com/vectordotdev/vector/issues/23659 +#[allow( + clippy::missing_panics_doc, + reason = "Audit and document the existing panic conditions separately from lint enforcement." +)] pub fn default_grpc_url() -> Url { let addr = default_address().unwrap(); Url::parse(&format!("http://{addr}")) @@ -56,6 +65,11 @@ pub fn default_grpc_url() -> Url { } impl Options { + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." + )] pub fn merge(&mut self, other: Self) -> Result<(), String> { // Merge options diff --git a/src/config/builder.rs b/src/config/builder.rs index dde60a63c73bb..728d7aad610dc 100644 --- a/src/config/builder.rs +++ b/src/config/builder.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use std::{path::Path, time::Duration}; use indexmap::IndexMap; @@ -132,6 +134,11 @@ impl From for ConfigBuilder { } impl ConfigBuilder { + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." + )] pub fn build(self) -> Result> { let (config, warnings) = self.build_with_warnings()?; @@ -142,6 +149,11 @@ impl ConfigBuilder { Ok(config) } + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." + )] pub fn build_with_warnings(self) -> Result<(Config, Vec), Vec> { compiler::compile(self) } @@ -154,7 +166,7 @@ impl ConfigBuilder { ) { let inputs = inputs .iter() - .map(|value| value.to_string()) + .map(std::string::ToString::to_string) .collect::>(); self.enrichment_tables.insert( ComponentKey::from(key.into()), @@ -175,7 +187,7 @@ impl ConfigBuilder { ) { let inputs = inputs .iter() - .map(|value| value.to_string()) + .map(std::string::ToString::to_string) .collect::>(); let sink = SinkOuter::new(inputs, sink); self.add_sink_outer(key, sink); @@ -195,7 +207,7 @@ impl ConfigBuilder { ) { let inputs = inputs .iter() - .map(|value| value.to_string()) + .map(std::string::ToString::to_string) .collect::>(); let transform = TransformOuter::new(inputs, transform); @@ -207,6 +219,11 @@ impl ConfigBuilder { self.global.data_dir = Some(path.to_owned()); } + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." + )] pub fn append(&mut self, with: Self) -> Result<(), Vec> { let mut errors = Vec::new(); @@ -273,11 +290,23 @@ impl ConfigBuilder { } #[cfg(test)] + #[must_use] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_panics_doc, + reason = "Audit and document the existing panic conditions separately from lint enforcement." + )] pub fn from_toml(input: &str) -> Self { crate::config::format::deserialize(input, crate::config::format::Format::Toml).unwrap() } #[cfg(test)] + #[must_use] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_panics_doc, + reason = "Audit and document the existing panic conditions separately from lint enforcement." + )] pub fn from_json(input: &str) -> Self { crate::config::format::deserialize(input, crate::config::format::Format::Json).unwrap() } diff --git a/src/config/compiler.rs b/src/config/compiler.rs index 888cc953c5d0e..b469460d3cfdb 100644 --- a/src/config/compiler.rs +++ b/src/config/compiler.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use indexmap::{IndexMap, IndexSet}; use std::sync::Arc; use vector_lib::config::ComponentKey; @@ -8,6 +10,11 @@ use super::{ sink::SinkOuter, transform::get_transform_output_ids, validation, }; +// https://github.com/vectordotdev/vector/issues/23659 +#[allow( + clippy::too_many_lines, + reason = "Keep the existing control flow intact during the lint rollout." +)] pub fn compile(mut builder: ConfigBuilder) -> Result<(Config, Vec), Vec> { let mut errors = Vec::new(); @@ -112,15 +119,15 @@ pub fn compile(mut builder: ConfigBuilder) -> Result<(Config, Vec), Vec< if errors.is_empty() { let mut config = Config { - global, #[cfg(feature = "api")] api, schema, + global, healthchecks, - enrichment_tables, sources, sinks, transforms, + enrichment_tables, tests, secret, graceful_shutdown_duration, @@ -166,11 +173,11 @@ pub(crate) fn expand_globs(config: &mut ConfigBuilder) { .map(|output_id| output_id.to_string()) .collect::>(); - for (id, transform) in config.transforms.iter_mut() { + for (id, transform) in &mut config.transforms { expand_globs_inner(&mut transform.inputs, &id.to_string(), &candidates); } - for (id, sink) in config.sinks.iter_mut() { + for (id, sink) in &mut config.sinks { expand_globs_inner(&mut sink.inputs, &id.to_string(), &candidates); } } @@ -184,7 +191,7 @@ fn validate_sinks(config: &mut Config) -> Vec { let mut errors = Vec::new(); // Validate direct sinks - for (key, sink) in config.sinks.iter_mut() { + for (key, sink) in &mut config.sinks { let dyn_sink: &dyn DynValidatedSink = sink.inner.as_ref(); match dyn_sink.validate_dyn() { Ok(state) => sink.validated = Some(Arc::from(state)), @@ -193,7 +200,7 @@ fn validate_sinks(config: &mut Config) -> Vec { } // Validate enrichment table sinks with resolved inputs. - for (key, table) in config.enrichment_tables.iter_mut() { + for (key, table) in &mut config.enrichment_tables { if let Some((_, sink)) = table.as_sink(key) { let dyn_sink: &dyn DynValidatedSink = sink.inner.as_ref(); match dyn_sink.validate_dyn() { @@ -215,7 +222,7 @@ enum InputMatcher { impl InputMatcher { fn matches(&self, candidate: &str) -> bool { - use InputMatcher::*; + use InputMatcher::{Pattern, String}; match self { Pattern(pattern) => pattern.matches(candidate), @@ -224,26 +231,32 @@ impl InputMatcher { } } +// https://github.com/vectordotdev/vector/issues/23659 +#[allow( + clippy::similar_names, + reason = "Keep established local names during the lint rollout; naming cleanup is deferred." +)] fn expand_globs_inner(inputs: &mut Inputs, id: &str, candidates: &IndexSet) { let raw_inputs = std::mem::take(inputs); for raw_input in raw_inputs { - let matcher = glob::Pattern::new(&raw_input) - .map(InputMatcher::Pattern) - .unwrap_or_else(|error| { + let matcher = glob::Pattern::new(&raw_input).map_or_else( + |error| { warn!(message = "Invalid glob pattern for input.", component_id = %id, %error); - InputMatcher::String(raw_input.to_string()) - }); + InputMatcher::String(raw_input.clone()) + }, + InputMatcher::Pattern, + ); let mut matched = false; for input in candidates { if matcher.matches(input) && input != id { matched = true; - inputs.extend(Some(input.to_string())) + inputs.extend(Some(input.clone())); } } // If it didn't work as a glob pattern, leave it in the inputs as-is. This lets us give // more accurate error messages about nonexistent inputs. if !matched { - inputs.extend(Some(raw_input)) + inputs.extend(Some(raw_input)); } } } diff --git a/src/config/component.rs b/src/config/component.rs index 65a217955f3aa..b6260d224a6e6 100644 --- a/src/config/component.rs +++ b/src/config/component.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use serde::Serialize; use strum::EnumDiscriminants; use vector_lib::configurable::{Configurable, ToValue}; @@ -64,6 +66,7 @@ impl<'a, T> Component<'a, T> where T: Configurable + Serialize + ToValue + Clone + 'static, { + #[must_use] pub fn kind(&self) -> ComponentKind { self.into() } @@ -72,6 +75,7 @@ where /// /// Enrichment table inputs belong to the table's derived sink. A derived /// source is a separate component, whose key may differ from the table key. + #[must_use] pub fn inputs(&self) -> Option<&'a [T]> { match self { Self::Source(_) => None, diff --git a/src/config/diff.rs b/src/config/diff.rs index 00d939c7a71b4..c71dc15545e79 100644 --- a/src/config/diff.rs +++ b/src/config/diff.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use std::collections::HashSet; use indexmap::IndexMap; @@ -15,10 +17,12 @@ pub struct ConfigDiff { } impl ConfigDiff { + #[must_use] pub fn initial(initial: &Config) -> Self { Self::new(&Config::default(), initial, HashSet::new()) } + #[must_use] pub fn new(old: &Config, new: &Config, components_to_reload: HashSet) -> Self { ConfigDiff { sources: Difference::new(&old.sources, &new.sources, &components_to_reload), @@ -34,6 +38,7 @@ impl ConfigDiff { } /// Swaps removed with added in Differences. + #[must_use] pub const fn flip(mut self) -> Self { self.sources.flip(); self.transforms.flip(); @@ -43,6 +48,7 @@ impl ConfigDiff { } /// Checks whether the given component is present at all. + #[must_use] pub fn contains(&self, key: &ComponentKey) -> bool { self.sources.contains(key) || self.transforms.contains(key) @@ -51,6 +57,7 @@ impl ConfigDiff { } /// Checks whether the given component is changed. + #[must_use] pub fn is_changed(&self, key: &ComponentKey) -> bool { self.sources.is_changed(key) || self.transforms.is_changed(key) @@ -59,6 +66,7 @@ impl ConfigDiff { } /// Checks whether the given component is removed. + #[must_use] pub fn is_removed(&self, key: &ComponentKey) -> bool { self.sources.is_removed(key) || self.transforms.is_removed(key) @@ -147,6 +155,11 @@ impl EnrichmentTableDiff { } #[derive(Debug)] +// https://github.com/vectordotdev/vector/issues/23659 +#[allow( + clippy::struct_field_names, + reason = "Preserve existing field names and their configuration or API contracts." +)] pub struct Difference { pub to_remove: HashSet, pub to_change: HashSet, @@ -402,7 +415,7 @@ mod tests { let diff = EnrichmentTableDiff::new( &old_config.enrichment_tables, &new_config.enrichment_tables, - &Default::default(), + &HashSet::default(), ); assert_eq!( @@ -482,7 +495,7 @@ mod tests { let diff = EnrichmentTableDiff::new( &old_config.enrichment_tables, &new_config.enrichment_tables, - &Default::default(), + &HashSet::default(), ); let table_key = ComponentKey::from("file_table"); @@ -547,7 +560,7 @@ mod tests { let diff = EnrichmentTableDiff::new( &old_config.enrichment_tables, &new_config.enrichment_tables, - &Default::default(), + &HashSet::default(), ); assert_eq!( diff --git a/src/config/enrichment_table.rs b/src/config/enrichment_table.rs index 72445404fbd7b..f894d9d35ce68 100644 --- a/src/config/enrichment_table.rs +++ b/src/config/enrichment_table.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use std::{any::Any, sync::Arc}; use enum_dispatch::enum_dispatch; @@ -50,7 +52,7 @@ where { Self { inner: inner.into(), - graph: Default::default(), + graph: GraphConfig::default(), inputs: Inputs::from_iter(inputs), validated: None, } @@ -68,6 +70,12 @@ where // components to deserialization and build up the components and the topology in a more granular // way, with each having "modules" for inputs (making them valid as sinks), for healthchecks, // for providing outputs, etc. + #[must_use] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::default_trait_access, + reason = "Keep inferred defaults where concrete type names need a separate import or API cleanup." + )] pub fn as_sink(&self, default_key: &ComponentKey) -> Option<(ComponentKey, SinkOuter)> { self.inner.sink_config(default_key).map(|(key, sink)| { ( @@ -86,6 +94,12 @@ where }) } + #[must_use] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::default_trait_access, + reason = "Keep inferred defaults where concrete type names need a separate import or API cleanup." + )] pub fn as_source(&self, default_key: &ComponentKey) -> Option<(ComponentKey, SourceOuter)> { self.inner.source_config(default_key).map(|(key, source)| { ( diff --git a/src/config/format.rs b/src/config/format.rs index 655339ed2b89a..e50710238ac93 100644 --- a/src/config/format.rs +++ b/src/config/format.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + //! Support for loading configs from multiple formats. #![deny(missing_docs, missing_debug_implementations)] @@ -62,10 +64,15 @@ impl fmt::Display for Format { impl Format { /// Obtain the format from the file path using extension as a hint. + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." + )] pub fn from_path>(path: T) -> Result { match path.as_ref().extension().and_then(|ext| ext.to_str()) { Some("toml") => Ok(Format::Toml), - Some("yaml") | Some("yml") => Ok(Format::Yaml), + Some("yaml" | "yml") => Ok(Format::Yaml), Some("json") => Ok(Format::Json), _ => Err(path), } @@ -73,6 +80,11 @@ impl Format { } /// Parse the string represented in the specified format. +// https://github.com/vectordotdev/vector/issues/23659 +#[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." +)] pub fn deserialize(content: &str, format: Format) -> Result> where T: de::DeserializeOwned, @@ -90,6 +102,11 @@ where } /// Serialize the specified `value` into a string. +// https://github.com/vectordotdev/vector/issues/23659 +#[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." +)] pub fn serialize(value: &T, format: Format) -> Result where T: serde::ser::Serialize, @@ -161,7 +178,7 @@ mod tests { for (input, expected) in cases { let output = Format::from_path(std::path::PathBuf::from(input)); - assert_eq!(expected, output.ok(), "{input}") + assert_eq!(expected, output.ok(), "{input}"); } } @@ -173,6 +190,11 @@ mod tests { feature = "sinks-socket" ))] #[test] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::too_many_lines, + reason = "Keep the existing control flow intact during the lint rollout." + )] fn test_deserialize_matches_toml() { use crate::config::ConfigBuilder; @@ -319,7 +341,7 @@ mod tests { let expected_output: ConfigBuilder = deserialize(expected, Format::Toml) .expect("Invalid TOML passed as an expectation"); let expected_json = serde_json::to_value(expected_output).unwrap(); - assert_eq!(expected_json, output_json, "{input}") + assert_eq!(expected_json, output_json, "{input}"); } Err(expected) => assert_eq!( expected, diff --git a/src/config/graph.rs b/src/config/graph.rs index d7c10eb796402..f5955e52eff4e 100644 --- a/src/config/graph.rs +++ b/src/config/graph.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use std::{ collections::{HashMap, HashSet, VecDeque}, fmt, @@ -265,13 +267,13 @@ impl Graph { traversal.push_back(s.to_owned()); while !traversal.is_empty() { let n = traversal.back().expect("can't be empty").clone(); - if !visited.contains(&n) { - visited.insert(n.clone()); - stack.insert(n.clone()); - } else { + if visited.contains(&n) { // we came back to the node after exploring all its children - remove it from the stack and traversal stack.shift_remove(&n); traversal.pop_back(); + } else { + visited.insert(n.clone()); + stack.insert(n.clone()); } let inputs = self .edges @@ -287,7 +289,7 @@ impl Graph { .iter() .skip(1) // skip the sink .rev() - .map(|item| item.to_string()) + .map(std::string::ToString::to_string) .collect::>(); return Err(format!( "Cyclic dependency detected in the chain [ {} -> {} ]", @@ -928,7 +930,7 @@ mod test { .collect(); assert_eq!(paths.len(), 1); - assert_eq!(paths[0], vec!["in", "one", "two", "three", "out"]) + assert_eq!(paths[0], vec!["in", "one", "two", "three", "out"]); } #[test] diff --git a/src/config/graph_builder.rs b/src/config/graph_builder.rs index 5764bce4d0eb3..e161f4422fcef 100644 --- a/src/config/graph_builder.rs +++ b/src/config/graph_builder.rs @@ -1,3 +1,5 @@ +#![warn(clippy::pedantic)] + use indexmap::IndexMap; use super::{ @@ -244,6 +246,11 @@ mod tests { } #[test] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::default_trait_access, + reason = "Keep inferred defaults where concrete type names need a separate import or API cleanup." + )] fn lookup_only_table_has_no_execution_nodes() { let mut config = ConfigBuilder::default(); config.add_enrichment_table( diff --git a/src/config/mod.rs b/src/config/mod.rs index 0fd0e4334401a..038d57becd382 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -89,6 +89,7 @@ pub struct ComponentConfig { } impl ComponentConfig { + #[must_use] pub fn new( config_paths: Vec, component_key: ComponentKey, @@ -106,6 +107,7 @@ impl ComponentConfig { } } + #[must_use] pub fn contains( &self, config_paths: &HashSet, @@ -124,6 +126,11 @@ pub enum ConfigPath { } impl<'a> From<&'a ConfigPath> for &'a PathBuf { + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::match_same_arms, + reason = "Keep the existing match structure and branch-specific context during the lint rollout." + )] fn from(config_path: &'a ConfigPath) -> &'a PathBuf { match config_path { ConfigPath::File(path, _) => path, @@ -133,6 +140,12 @@ impl<'a> From<&'a ConfigPath> for &'a PathBuf { } impl ConfigPath { + #[must_use] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::match_wildcard_for_single_variants, + reason = "Keep the existing branching and control flow during the lint rollout." + )] pub const fn as_dir(&self) -> Option<&PathBuf> { match self { Self::Dir(path) => Some(path), @@ -158,10 +171,12 @@ pub struct Config { } impl Config { + #[must_use] pub fn builder() -> builder::ConfigBuilder { - Default::default() + ConfigBuilder::default() } + #[must_use] pub fn is_empty(&self) -> bool { self.sources.is_empty() } @@ -170,6 +185,7 @@ impl Config { self.sources.iter() } + #[must_use] pub fn source(&self, id: &ComponentKey) -> Option<&SourceOuter> { self.sources.get(id) } @@ -178,6 +194,7 @@ impl Config { self.transforms.iter() } + #[must_use] pub fn transform(&self, id: &ComponentKey) -> Option<&TransformOuter> { self.transforms.get(id) } @@ -186,6 +203,7 @@ impl Config { self.sinks.iter() } + #[must_use] pub fn sink(&self, id: &ComponentKey) -> Option<&SinkOuter> { self.sinks.get(id) } @@ -196,6 +214,7 @@ impl Config { self.enrichment_tables.iter() } + #[must_use] pub fn enrichment_table(&self, id: &ComponentKey) -> Option<&EnrichmentTableOuter> { self.enrichment_tables.get(id) } @@ -224,6 +243,11 @@ impl Config { .and_then(|component| component.inputs()) } + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::missing_errors_doc, + reason = "Audit and document the existing error contracts separately from lint enforcement." + )] pub fn propagate_acknowledgements(&mut self) -> Result<(), Vec> { let inputs: Vec<_> = self .sinks @@ -268,14 +292,15 @@ impl Config { } } + #[must_use] pub fn transform_keys_with_external_files(&self) -> HashSet { self.transforms .iter() .filter_map(|(name, transform_outer)| { - if !transform_outer.inner.files_to_watch().is_empty() { - Some(name.clone()) - } else { + if transform_outer.inner.files_to_watch().is_empty() { None + } else { + Some(name.clone()) } }) .collect() @@ -340,10 +365,12 @@ pub enum Protocol { } impl Resource { + #[must_use] pub const fn tcp(addr: SocketAddr) -> Self { Self::Port(addr, Protocol::Tcp) } + #[must_use] pub const fn udp(addr: SocketAddr) -> Self { Self::Port(addr, Protocol::Udp) } @@ -375,7 +402,7 @@ impl Resource { // so we have to check for all Port resources if they share the same // port. for (key, address0, protocol0) in unspecified { - for (resource, components) in resource_map.iter_mut() { + for (resource, components) in &mut resource_map { if let Resource::Port(address, protocol) = resource { // IP addresses can either be v4 or v6. // Therefore we check if the ip version matches, the port matches and if the protocol (TCP/UDP) matches @@ -467,13 +494,13 @@ impl TestDefinition { for from in extract_from { if no_outputs_from.contains(&from) { errors.push(format!( - r#"Invalid extract_from target in test '{name}': '{from}' listed in no_outputs_from"# + r"Invalid extract_from target in test '{name}': '{from}' listed in no_outputs_from" )); } else if let Some(output_id) = output_map.get(&from) { outputs.push(output_id.clone()); } else { errors.push(format!( - r#"Invalid extract_from target in test '{name}': '{from}' does not exist"# + r"Invalid extract_from target in test '{name}': '{from}' does not exist" )); } } @@ -496,7 +523,7 @@ impl TestDefinition { Some(output_id.clone()) } else { errors.push(format!( - r#"Invalid no_outputs_from target in test '{name}': '{o}' does not exist"# + r"Invalid no_outputs_from target in test '{name}': '{o}' does not exist" )); None } @@ -561,6 +588,11 @@ impl TestDefinition { #[configurable_component] #[derive(Clone, Debug)] #[serde(deny_unknown_fields)] +// https://github.com/vectordotdev/vector/issues/23659 +#[allow( + clippy::doc_markdown, + reason = "Defer the remaining documentation formatting until its source or generator is audited." +)] pub struct TestInput { /// The name of the transform to insert the input event to. pub insert_at: ComponentKey, @@ -835,7 +867,7 @@ mod tests { "Transform \"sample2\" has no consumers", "Source \"in2\" has no consumers", ] - ) + ); } #[tokio::test] @@ -881,7 +913,7 @@ mod tests { assert_eq!( errors, vec!["Cyclic dependency detected in the chain [ four -> two -> three -> four ]"] - ) + ); } #[test] @@ -902,7 +934,7 @@ mod tests { assert_eq!( Some(PathBuf::from("/var/lib/vector")), config.global.data_dir - ) + ); } #[test] @@ -1405,6 +1437,11 @@ mod resource_config_tests { #[ignore] #[allow(clippy::print_stdout)] #[allow(clippy::print_stderr)] + // https://github.com/vectordotdev/vector/issues/23659 + #[allow( + clippy::ignore_without_reason, + reason = "Retain this pre-existing ignored test until its prerequisites and failure mode are documented." + )] fn generate_component_config_schema() { use indexmap::IndexMap; use vector_lib::{config::ComponentKey, configurable::configurable_component}; From dc53606cc9ccabfe435bdd4bf116e35b472d7ff2 Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Thu, 8 Oct 2026 13:11:45 -0400 Subject: [PATCH 2/2] chore: Shorten Clippy allowance reasons --- src/config/api.rs | 10 ++-------- src/config/builder.rs | 25 +++++-------------------- src/config/compiler.rs | 10 ++-------- src/config/diff.rs | 2 +- src/config/enrichment_table.rs | 4 ++-- src/config/format.rs | 20 ++++---------------- src/config/graph_builder.rs | 2 +- src/config/mod.rs | 19 +++++-------------- 8 files changed, 22 insertions(+), 70 deletions(-) diff --git a/src/config/api.rs b/src/config/api.rs index 0ad416614d849..11b38b1c7894d 100644 --- a/src/config/api.rs +++ b/src/config/api.rs @@ -54,10 +54,7 @@ pub fn default_address() -> Option { /// Default gRPC API address for `vector top` and other API clients #[must_use] // https://github.com/vectordotdev/vector/issues/23659 -#[allow( - clippy::missing_panics_doc, - reason = "Audit and document the existing panic conditions separately from lint enforcement." -)] +#[allow(clippy::missing_panics_doc, reason = "Panic documentation deferred")] pub fn default_grpc_url() -> Url { let addr = default_address().unwrap(); Url::parse(&format!("http://{addr}")) @@ -66,10 +63,7 @@ pub fn default_grpc_url() -> Url { impl Options { // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." - )] + #[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn merge(&mut self, other: Self) -> Result<(), String> { // Merge options diff --git a/src/config/builder.rs b/src/config/builder.rs index 728d7aad610dc..a1f01286214f1 100644 --- a/src/config/builder.rs +++ b/src/config/builder.rs @@ -135,10 +135,7 @@ impl From for ConfigBuilder { impl ConfigBuilder { // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." - )] + #[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn build(self) -> Result> { let (config, warnings) = self.build_with_warnings()?; @@ -150,10 +147,7 @@ impl ConfigBuilder { } // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." - )] + #[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn build_with_warnings(self) -> Result<(Config, Vec), Vec> { compiler::compile(self) } @@ -220,10 +214,7 @@ impl ConfigBuilder { } // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." - )] + #[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn append(&mut self, with: Self) -> Result<(), Vec> { let mut errors = Vec::new(); @@ -292,10 +283,7 @@ impl ConfigBuilder { #[cfg(test)] #[must_use] // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_panics_doc, - reason = "Audit and document the existing panic conditions separately from lint enforcement." - )] + #[allow(clippy::missing_panics_doc, reason = "Panic documentation deferred")] pub fn from_toml(input: &str) -> Self { crate::config::format::deserialize(input, crate::config::format::Format::Toml).unwrap() } @@ -303,10 +291,7 @@ impl ConfigBuilder { #[cfg(test)] #[must_use] // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_panics_doc, - reason = "Audit and document the existing panic conditions separately from lint enforcement." - )] + #[allow(clippy::missing_panics_doc, reason = "Panic documentation deferred")] pub fn from_json(input: &str) -> Self { crate::config::format::deserialize(input, crate::config::format::Format::Json).unwrap() } diff --git a/src/config/compiler.rs b/src/config/compiler.rs index b469460d3cfdb..c01169d9198f1 100644 --- a/src/config/compiler.rs +++ b/src/config/compiler.rs @@ -11,10 +11,7 @@ use super::{ }; // https://github.com/vectordotdev/vector/issues/23659 -#[allow( - clippy::too_many_lines, - reason = "Keep the existing control flow intact during the lint rollout." -)] +#[allow(clippy::too_many_lines, reason = "Preserve existing control flow")] pub fn compile(mut builder: ConfigBuilder) -> Result<(Config, Vec), Vec> { let mut errors = Vec::new(); @@ -232,10 +229,7 @@ impl InputMatcher { } // https://github.com/vectordotdev/vector/issues/23659 -#[allow( - clippy::similar_names, - reason = "Keep established local names during the lint rollout; naming cleanup is deferred." -)] +#[allow(clippy::similar_names, reason = "Naming cleanup deferred")] fn expand_globs_inner(inputs: &mut Inputs, id: &str, candidates: &IndexSet) { let raw_inputs = std::mem::take(inputs); for raw_input in raw_inputs { diff --git a/src/config/diff.rs b/src/config/diff.rs index c71dc15545e79..8e78c344de971 100644 --- a/src/config/diff.rs +++ b/src/config/diff.rs @@ -158,7 +158,7 @@ impl EnrichmentTableDiff { // https://github.com/vectordotdev/vector/issues/23659 #[allow( clippy::struct_field_names, - reason = "Preserve existing field names and their configuration or API contracts." + reason = "Preserve field names and API contracts" )] pub struct Difference { pub to_remove: HashSet, diff --git a/src/config/enrichment_table.rs b/src/config/enrichment_table.rs index f894d9d35ce68..0629e888a92a4 100644 --- a/src/config/enrichment_table.rs +++ b/src/config/enrichment_table.rs @@ -74,7 +74,7 @@ where // https://github.com/vectordotdev/vector/issues/23659 #[allow( clippy::default_trait_access, - reason = "Keep inferred defaults where concrete type names need a separate import or API cleanup." + reason = "Preserve inferred default types" )] pub fn as_sink(&self, default_key: &ComponentKey) -> Option<(ComponentKey, SinkOuter)> { self.inner.sink_config(default_key).map(|(key, sink)| { @@ -98,7 +98,7 @@ where // https://github.com/vectordotdev/vector/issues/23659 #[allow( clippy::default_trait_access, - reason = "Keep inferred defaults where concrete type names need a separate import or API cleanup." + reason = "Preserve inferred default types" )] pub fn as_source(&self, default_key: &ComponentKey) -> Option<(ComponentKey, SourceOuter)> { self.inner.source_config(default_key).map(|(key, source)| { diff --git a/src/config/format.rs b/src/config/format.rs index e50710238ac93..ad72176c7fba4 100644 --- a/src/config/format.rs +++ b/src/config/format.rs @@ -65,10 +65,7 @@ impl fmt::Display for Format { impl Format { /// Obtain the format from the file path using extension as a hint. // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." - )] + #[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn from_path>(path: T) -> Result { match path.as_ref().extension().and_then(|ext| ext.to_str()) { Some("toml") => Ok(Format::Toml), @@ -81,10 +78,7 @@ impl Format { /// Parse the string represented in the specified format. // https://github.com/vectordotdev/vector/issues/23659 -#[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." -)] +#[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn deserialize(content: &str, format: Format) -> Result> where T: de::DeserializeOwned, @@ -103,10 +97,7 @@ where /// Serialize the specified `value` into a string. // https://github.com/vectordotdev/vector/issues/23659 -#[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." -)] +#[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn serialize(value: &T, format: Format) -> Result where T: serde::ser::Serialize, @@ -191,10 +182,7 @@ mod tests { ))] #[test] // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::too_many_lines, - reason = "Keep the existing control flow intact during the lint rollout." - )] + #[allow(clippy::too_many_lines, reason = "Preserve existing control flow")] fn test_deserialize_matches_toml() { use crate::config::ConfigBuilder; diff --git a/src/config/graph_builder.rs b/src/config/graph_builder.rs index e161f4422fcef..d32f8468da5ad 100644 --- a/src/config/graph_builder.rs +++ b/src/config/graph_builder.rs @@ -249,7 +249,7 @@ mod tests { // https://github.com/vectordotdev/vector/issues/23659 #[allow( clippy::default_trait_access, - reason = "Keep inferred defaults where concrete type names need a separate import or API cleanup." + reason = "Preserve inferred default types" )] fn lookup_only_table_has_no_execution_nodes() { let mut config = ConfigBuilder::default(); diff --git a/src/config/mod.rs b/src/config/mod.rs index 038d57becd382..ee897487bb0b0 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -127,10 +127,7 @@ pub enum ConfigPath { impl<'a> From<&'a ConfigPath> for &'a PathBuf { // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::match_same_arms, - reason = "Keep the existing match structure and branch-specific context during the lint rollout." - )] + #[allow(clippy::match_same_arms, reason = "Preserve branch-specific context")] fn from(config_path: &'a ConfigPath) -> &'a PathBuf { match config_path { ConfigPath::File(path, _) => path, @@ -144,7 +141,7 @@ impl ConfigPath { // https://github.com/vectordotdev/vector/issues/23659 #[allow( clippy::match_wildcard_for_single_variants, - reason = "Keep the existing branching and control flow during the lint rollout." + reason = "Preserve existing control flow" )] pub const fn as_dir(&self) -> Option<&PathBuf> { match self { @@ -244,10 +241,7 @@ impl Config { } // https://github.com/vectordotdev/vector/issues/23659 - #[allow( - clippy::missing_errors_doc, - reason = "Audit and document the existing error contracts separately from lint enforcement." - )] + #[allow(clippy::missing_errors_doc, reason = "Error documentation deferred")] pub fn propagate_acknowledgements(&mut self) -> Result<(), Vec> { let inputs: Vec<_> = self .sinks @@ -589,10 +583,7 @@ impl TestDefinition { #[derive(Clone, Debug)] #[serde(deny_unknown_fields)] // https://github.com/vectordotdev/vector/issues/23659 -#[allow( - clippy::doc_markdown, - reason = "Defer the remaining documentation formatting until its source or generator is audited." -)] +#[allow(clippy::doc_markdown, reason = "Documentation formatting deferred")] pub struct TestInput { /// The name of the transform to insert the input event to. pub insert_at: ComponentKey, @@ -1440,7 +1431,7 @@ mod resource_config_tests { // https://github.com/vectordotdev/vector/issues/23659 #[allow( clippy::ignore_without_reason, - reason = "Retain this pre-existing ignored test until its prerequisites and failure mode are documented." + reason = "Ignored test needs documentation" )] fn generate_component_config_schema() { use indexmap::IndexMap;