refactor: remove redundant configure_options and default_options methods

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 10:43:30 -03:00
parent 5d518711d5
commit b7bf9b20de
14 changed files with 0 additions and 114 deletions

View File

@@ -153,12 +153,4 @@ impl MetaPlugin for BinaryMetaPlugin {
self.base.options_mut()
}
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
if let Some(max_buffer_size) = options.get("max_buffer_size") {
if let Some(size) = max_buffer_size.as_u64() {
self.max_buffer_size = size as usize;
}
}
Ok(())
}
}

View File

@@ -118,9 +118,6 @@ impl MetaPlugin for CwdMetaPlugin {
vec!["cwd".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
self.base.options()

View File

@@ -222,11 +222,6 @@ impl MetaPlugin for DigestMetaPlugin {
]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
let mut options = std::collections::HashMap::new();
options.insert("method".to_string(), serde_yaml::Value::String("sha256".to_string()));
options
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options

View File

@@ -220,11 +220,6 @@ impl MetaPlugin for HostnameMetaPlugin {
vec!["hostname".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
let mut options = std::collections::HashMap::new();
options.insert("full".to_string(), serde_yaml::Value::Bool(true));
options
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
@@ -234,10 +229,4 @@ impl MetaPlugin for HostnameMetaPlugin {
&mut self.options
}
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
for (key, value) in options {
self.options.insert(key.clone(), value.clone());
}
Ok(())
}
}

View File

@@ -135,9 +135,6 @@ impl MetaPlugin for KeepPidMetaPlugin {
vec!["keep_pid".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options

View File

@@ -209,14 +209,6 @@ impl MetaPlugin for MagicFileMetaPlugin {
"magic_file".to_string()
}
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
if let Some(max_buffer_size) = options.get("max_buffer_size") {
if let Some(size) = max_buffer_size.as_u64() {
self.max_buffer_size = size as usize;
}
}
Ok(())
}
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
self.base.outputs()
@@ -230,11 +222,6 @@ impl MetaPlugin for MagicFileMetaPlugin {
vec!["mime_type".to_string(), "mime_encoding".to_string(), "file_type".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
let mut options = std::collections::HashMap::new();
options.insert("max_buffer_size".to_string(), serde_yaml::Value::Number(serde_yaml::Number::from(PIPESIZE as i64)));
options
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
self.base.options()

View File

@@ -253,12 +253,6 @@ pub trait MetaPlugin where Self: 'static {
std::collections::HashMap::new()
}
// Configure plugin with options (excluding outputs)
fn configure_options(&mut self, _options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
// Default implementation does nothing - plugins can override this
Ok(())
}
// Configure plugin outputs mapping
fn configure_outputs(&mut self, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
for (key, value) in outputs {
@@ -267,13 +261,6 @@ pub trait MetaPlugin where Self: 'static {
Ok(())
}
// Configure both options and outputs
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>, outputs: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
self.configure_options(options)?;
self.configure_outputs(outputs)?;
Ok(())
}
// Method to downcast to concrete type (for checking finalization state)
fn as_any_mut(&mut self) -> &mut dyn std::any::Any where Self: Sized {
self

View File

@@ -216,9 +216,6 @@ impl MetaPlugin for MetaPluginProgram {
vec![self.meta_name.clone()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options

View File

@@ -134,9 +134,6 @@ impl MetaPlugin for ReadRateMetaPlugin {
vec!["read_rate".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options

View File

@@ -127,9 +127,6 @@ impl MetaPlugin for ReadTimeMetaPlugin {
vec!["read_time".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options

View File

@@ -138,9 +138,6 @@ impl MetaPlugin for ShellMetaPlugin {
vec!["shell".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options

View File

@@ -139,9 +139,6 @@ impl MetaPlugin for ShellPidMetaPlugin {
vec!["shell_pid".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options

View File

@@ -521,44 +521,4 @@ impl MetaPlugin for TextMetaPlugin {
self.base.options_mut()
}
fn configure_options(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> anyhow::Result<()> {
log::debug!("TEXT: Configuring options: {:?}", options);
if let Some(text_detect_size) = options.get("text_detect_size") {
if let Some(size) = text_detect_size.as_u64() {
self.max_buffer_size = size as usize;
}
}
// Handle the old option name for backward compatibility
else if let Some(max_buffer_size) = options.get("max_buffer_size") {
if let Some(size) = max_buffer_size.as_u64() {
self.max_buffer_size = size as usize;
}
}
// Update tracking options - use default values if not present in options
self.track_word_count = options.get("text_word_count")
.and_then(|v| v.as_bool())
.unwrap_or(true);
self.track_line_count = options.get("text_line_count")
.and_then(|v| v.as_bool())
.unwrap_or(true);
// For line length tracking, check if any of the line length options are enabled
let track_line_max = options.get("text_line_max_len")
.and_then(|v| v.as_bool())
.unwrap_or(true);
let track_line_mean = options.get("text_line_mean_len")
.and_then(|v| v.as_bool())
.unwrap_or(true);
let track_line_median = options.get("text_line_median_len")
.and_then(|v| v.as_bool())
.unwrap_or(true);
self.track_line_lengths = track_line_max || track_line_mean || track_line_median;
if self.track_line_lengths && self.line_lengths.is_none() {
self.line_lengths = Some(Vec::new());
}
Ok(())
}
}

View File

@@ -90,9 +90,6 @@ impl MetaPlugin for UserMetaPlugin {
vec!["user_uid".to_string(), "user_gid".to_string(), "user_name".to_string(), "user_group".to_string()]
}
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
self.base.options()