Skip to content

Commit 5d13d0f

Browse files
committed
Improve code quality with linting fixes and cleanup
- Added rustfmt.toml and .clippy.toml configuration files - Fixed redundant closures by using direct function references - Marked unused variables with underscores - Added #[allow(dead_code)] attributes to public API functions - Simplified return statements and improved code patterns - Fixed error handling in async functions - All tests passing with no Clippy warnings in main code
1 parent 334de8f commit 5d13d0f

18 files changed

+895
-739
lines changed

.clippy.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Allow code that would be automatically fixed by rustfmt
2+
cognitive-complexity-threshold = 25
3+
too-many-arguments-threshold = 7
4+
disallowed-methods = []

rustfmt.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
max_width = 100
2+
hard_tabs = false
3+
tab_spaces = 4
4+
newline_style = "Auto"
5+
use_small_heuristics = "Default"
6+
reorder_imports = true
7+
reorder_modules = true
8+
remove_nested_parens = true
9+
edition = "2021"
10+
merge_derives = true
11+
use_field_init_shorthand = true
12+
use_try_shorthand = true
13+
format_strings = true

src/config.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
use anyhow::Result;
22
use std::path::Path;
3-
use tracing;
43

54
/// Configuration for scanning
65
#[derive(Debug, Clone)]
76
pub struct ScanConfig {
87
/// Path to input file with domains, one per line
98
pub input_file: String,
10-
9+
1110
/// Path to rules file
1211
pub rules_file: String,
13-
12+
1413
/// Number of concurrent scanners
1514
pub concurrency: usize,
16-
15+
1716
/// Verbosity level: 0=error, 1=warn, 2=info, 3=debug, 4=trace
1817
pub verbosity: u8,
19-
18+
2019
/// Whether to use distributed mode
2120
pub distributed: bool,
22-
21+
2322
/// Path to output file
2423
pub output_file: Option<String>,
2524

@@ -71,6 +70,7 @@ impl Default for ScanConfig {
7170

7271
impl ScanConfig {
7372
/// Create a new scan configuration with default values
73+
#[allow(dead_code)]
7474
pub fn new(input_file: String, rules_file: String) -> Self {
7575
Self {
7676
input_file,
@@ -89,35 +89,32 @@ impl ScanConfig {
8989
verbose: false,
9090
}
9191
}
92-
92+
9393
/// Validate the configuration
9494
pub fn validate(&self) -> Result<()> {
9595
// Check if input file exists
9696
if !Path::new(&self.input_file).exists() {
9797
anyhow::bail!("input file does not exist: {}", self.input_file);
9898
}
99-
99+
100100
// Check if rules file exists
101101
if !Path::new(&self.rules_file).exists() {
102102
anyhow::bail!("Rules file does not exist: {}", self.rules_file);
103103
}
104-
104+
105105
// Check concurrency value
106106
if self.concurrency == 0 {
107107
anyhow::bail!("Invalid concurrency value: must be greater than 0");
108108
}
109-
109+
110110
Ok(())
111111
}
112-
112+
113113
/// Log the configuration
114114
pub fn log_config(&self) {
115115
// Use event-based tracing which is more reliably captured by test infrastructure
116-
tracing::event!(
117-
tracing::Level::INFO,
118-
message = "Configuration:"
119-
);
120-
116+
tracing::event!(tracing::Level::INFO, message = "Configuration:");
117+
121118
// Log each configuration value as a separate event for better test capturing
122119
tracing::event!(
123120
tracing::Level::INFO,
@@ -189,7 +186,7 @@ impl ScanConfig {
189186
verbose = self.verbose,
190187
message = format!(" verbose: {}", self.verbose)
191188
);
192-
189+
193190
tracing::event!(
194191
tracing::Level::DEBUG,
195192
message = "Configuration validated successfully"

0 commit comments

Comments
 (0)