refactor: simplify filter plugin signatures by removing boxed parameters
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
9c354d5ef4
commit
059bde09e4
@@ -385,28 +385,26 @@ impl TextMetaPlugin {
|
||||
///
|
||||
/// * `Option<MetaData>` - Metadata entry if enabled and data exists.
|
||||
fn output_median_line_length_metadata(&self) -> Option<crate::meta_plugin::MetaData> {
|
||||
if self.output_line_median_len {
|
||||
if let Some(lengths) = &self.line_lengths {
|
||||
if !lengths.is_empty() {
|
||||
let mut sorted_lengths = lengths.clone();
|
||||
sorted_lengths.sort();
|
||||
let median_len = if lengths.len() % 2 == 0 {
|
||||
(sorted_lengths[lengths.len() / 2 - 1] + sorted_lengths[lengths.len() / 2]) as f64 / 2.0
|
||||
} else {
|
||||
sorted_lengths[lengths.len() / 2] as f64
|
||||
};
|
||||
|
||||
return crate::meta_plugin::process_metadata_outputs(
|
||||
"text_line_median_len",
|
||||
serde_yaml::Value::String(median_len.to_string()),
|
||||
self.base.outputs()
|
||||
);
|
||||
}
|
||||
if self.output_line_median_len
|
||||
&& let Some(lengths) = &self.line_lengths {
|
||||
if !lengths.is_empty() {
|
||||
let mut sorted_lengths = lengths.clone();
|
||||
sorted_lengths.sort();
|
||||
let median_len = if lengths.len() % 2 == 0 {
|
||||
(sorted_lengths[lengths.len() / 2 - 1] + sorted_lengths[lengths.len() / 2]) as f64 / 2.0
|
||||
} else {
|
||||
sorted_lengths[lengths.len() / 2] as f64
|
||||
};
|
||||
|
||||
return crate::meta_plugin::process_metadata_outputs(
|
||||
"text_line_median_len",
|
||||
serde_yaml::Value::String(median_len.to_string()),
|
||||
self.base.outputs()
|
||||
);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
/// Helper method to output word and line counts.
|
||||
///
|
||||
@@ -476,7 +474,6 @@ impl MetaPlugin for TextMetaPlugin {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Updates the plugin with new data chunk.
|
||||
///
|
||||
/// Accumulates data for binary detection (if pending) or text statistics.
|
||||
@@ -756,4 +753,4 @@ fn register_text_plugin() {
|
||||
register_meta_plugin(MetaPluginType::Text, |options, outputs| {
|
||||
Box::new(TextMetaPlugin::new(options, outputs))
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user