Skip to content

Commit 3e1bb69

Browse files
committed
Resolve merge conflicts: keep develop branch changes for v0.1.7 release
2 parents ea17d5b + 99ed26a commit 3e1bb69

File tree

6 files changed

+45
-42
lines changed

6 files changed

+45
-42
lines changed

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: d.o.it
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

crates/core/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ max_file_size = 20971520
103103
assert_eq!(config.output_formats, vec!["json", "csv"]);
104104
assert_eq!(config.database_path, "test.db");
105105
assert_eq!(config.max_threads, 4);
106-
assert_eq!(config.cache_size, 100000);
106+
assert_eq!(config.cache_size, 100_000);
107107
assert_eq!(config.batch_size, 200);
108-
assert_eq!(config.max_file_size, 20971520);
108+
assert_eq!(config.max_file_size, 20_971_520);
109109
}
110110

111111
#[test]
@@ -130,7 +130,7 @@ max_file_size = 20971520
130130
assert_eq!(config.max_threads, 8);
131131
assert_eq!(config.cache_size, 75000);
132132
assert_eq!(config.batch_size, 150);
133-
assert_eq!(config.max_file_size, 15728640);
133+
assert_eq!(config.max_file_size, 15_728_640);
134134
}
135135

136136
#[test]

crates/core/src/custom_detectors.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl CustomDetectorManager {
159159
let configs: Vec<CustomDetectorConfig> =
160160
match config_file.extension().and_then(|s| s.to_str()) {
161161
Some("json") => serde_json::from_str(&content)?,
162-
Some("yaml") | Some("yml") => serde_yaml::from_str(&content)?,
162+
Some("yaml" | "yml") => serde_yaml::from_str(&content)?,
163163
Some("toml") => toml::from_str(&content)?,
164164
_ => return Err(anyhow::anyhow!("Unsupported config file format")),
165165
};
@@ -190,7 +190,7 @@ impl CustomDetectorManager {
190190
let config_file = config_file.as_ref();
191191
let content = match config_file.extension().and_then(|s| s.to_str()) {
192192
Some("json") => serde_json::to_string_pretty(&configs)?,
193-
Some("yaml") | Some("yml") => serde_yaml::to_string(&configs)?,
193+
Some("yaml" | "yml") => serde_yaml::to_string(&configs)?,
194194
Some("toml") => toml::to_string_pretty(&configs)?,
195195
_ => return Err(anyhow::anyhow!("Unsupported config file format")),
196196
};
@@ -291,7 +291,7 @@ impl CustomDetectorManager {
291291
CustomDetectorConfig {
292292
name: "LARGE_FUNCTION".to_string(),
293293
description: "Detect functions that might be too large".to_string(),
294-
pattern: r#"fn\s+\w+[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]{500,}\}"#.to_string(),
294+
pattern: r"fn\s+\w+[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]{500,}\}".to_string(),
295295
file_extensions: vec!["rs".to_string()],
296296
case_sensitive: true,
297297
multiline: true,
@@ -534,8 +534,8 @@ mod tests {
534534
assert_eq!(matches_rs.len(), 1);
535535

536536
// Should not match .js file
537-
let matches_js = detector.detect(content, Path::new("test.js"));
538-
assert_eq!(matches_js.len(), 0);
537+
let js_matches = detector.detect(content, Path::new("test.js"));
538+
assert_eq!(js_matches.len(), 0);
539539
}
540540

541541
#[test]

crates/core/src/detectors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ fn detect_pattern_with_context(
5454
// Extract more context around the match
5555
let context_start = mat.start().saturating_sub(10);
5656
let context_end = (mat.end() + 20).min(line.len());
57-
let context = &line[context_start..context_end];
57+
let match_context = &line[context_start..context_end];
5858

5959
matches.push(Match {
6060
file_path: file_path.to_string_lossy().to_string(),
6161
line_number: line_idx + 1,
6262
column: mat.start() + 1,
6363
pattern: pattern_name.to_string(),
64-
message: format!("{}: {}", pattern_name, context.trim()),
64+
message: format!("{}: {}", pattern_name, match_context.trim()),
6565
});
6666
}
6767
}
@@ -484,7 +484,7 @@ impl PatternDetector for HighPerformanceDetector {
484484
// Extract context around the match
485485
let start = mat.start().saturating_sub(15);
486486
let end = (mat.end() + 25).min(content.len());
487-
let context = &content[start..end];
487+
let match_context = &content[start..end];
488488

489489
// Find the line number
490490
let line_start = content[..mat.start()]
@@ -499,7 +499,7 @@ impl PatternDetector for HighPerformanceDetector {
499499
line_number,
500500
column,
501501
pattern: pattern_name.clone(),
502-
message: format!("{}: {}", pattern_name, context.trim()),
502+
message: format!("{}: {}", pattern_name, match_context.trim()),
503503
});
504504
}
505505

crates/core/src/llm_detectors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ fn detect_pattern_with_context(
145145
for mat in re.find_iter(line) {
146146
let context_start = mat.start().saturating_sub(15);
147147
let context_end = (mat.end() + 25).min(line.len());
148-
let context = &line[context_start..context_end];
148+
let match_context = &line[context_start..context_end];
149149

150150
matches.push(Match {
151151
file_path: file_path.to_string_lossy().to_string(),
152152
line_number: line_idx + 1,
153153
column: mat.start() + 1,
154154
pattern: pattern_name.to_string(),
155-
message: format!("{}: {}", pattern_name, context.trim()),
155+
message: format!("{}: {}", pattern_name, match_context.trim()),
156156
});
157157
}
158158
}

crates/core/src/optimized_scanner.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ impl OptimizedScanner {
4040
}
4141
}
4242

43-
/// Set maximum cache size
43+
/// Set cache size
4444
pub fn with_cache_size(mut self, size: usize) -> Self {
4545
self.max_cache_size = size;
4646
self
4747
}
4848

49-
/// Gets the relevant detectors for a specific file extension
49+
/// Check if a file should be scanned based on size and type
5050
/// This optimizes performance by only running detectors that are likely to match
5151
fn get_relevant_detectors(&self, path: &Path) -> Vec<&dyn PatternDetector> {
5252
let ext = path.extension().and_then(|e| e.to_str());
@@ -56,19 +56,19 @@ impl OptimizedScanner {
5656
// For Rust files, prioritize Rust-specific detectors but include general ones
5757
self.detectors.iter().map(|d| d.as_ref()).collect()
5858
}
59-
Some("js") | Some("ts") | Some("jsx") | Some("tsx") | Some("vue") | Some("svelte") => {
59+
Some("js" | "ts" | "jsx" | "tsx" | "vue" | "svelte") => {
6060
// For JS/TS files, include all detectors
6161
self.detectors.iter().map(|d| d.as_ref()).collect()
6262
}
63-
Some("py") | Some("pyw") | Some("pyx") => {
63+
Some("py" | "pyw" | "pyx") => {
6464
// For Python files, include all detectors
6565
self.detectors.iter().map(|d| d.as_ref()).collect()
6666
}
6767
Some("java") => {
6868
// For Java files, include all detectors
6969
self.detectors.iter().map(|d| d.as_ref()).collect()
7070
}
71-
Some("c") | Some("cpp") | Some("cc") | Some("cxx") | Some("h") | Some("hpp") => {
71+
Some("c" | "cpp" | "cc" | "cxx" | "h" | "hpp") => {
7272
// For C/C++ files, include all detectors
7373
self.detectors.iter().map(|d| d.as_ref()).collect()
7474
}
@@ -84,12 +84,11 @@ impl OptimizedScanner {
8484
// For Ruby files, include all detectors
8585
self.detectors.iter().map(|d| d.as_ref()).collect()
8686
}
87-
Some("sh") | Some("bash") | Some("zsh") => {
87+
Some("sh" | "bash" | "zsh") => {
8888
// For shell scripts, include all detectors
8989
self.detectors.iter().map(|d| d.as_ref()).collect()
9090
}
91-
Some("json") | Some("yaml") | Some("yml") | Some("toml") | Some("xml")
92-
| Some("ini") | Some("cfg") => {
91+
Some("json" | "yaml" | "yml" | "toml" | "xml" | "ini" | "cfg") => {
9392
// For config files, include general detectors (TODO, FIXME, etc.)
9493
self.detectors.iter().map(|d| d.as_ref()).collect()
9594
}
@@ -331,24 +330,17 @@ impl StreamingScanner {
331330

332331
match ext {
333332
Some("rs") => self.detectors.iter().map(|d| d.as_ref()).collect(),
334-
Some("js") | Some("ts") | Some("jsx") | Some("tsx") | Some("vue") | Some("svelte") => {
333+
Some("js" | "ts" | "jsx" | "tsx" | "vue" | "svelte") => {
335334
self.detectors.iter().map(|d| d.as_ref()).collect()
336335
}
337-
Some("py") | Some("pyw") | Some("pyx") => {
336+
Some("py" | "pyw" | "pyx") => self.detectors.iter().map(|d| d.as_ref()).collect(),
337+
Some("c" | "cpp" | "cc" | "cxx" | "h" | "hpp") => {
338338
self.detectors.iter().map(|d| d.as_ref()).collect()
339339
}
340-
Some("java") => self.detectors.iter().map(|d| d.as_ref()).collect(),
341-
Some("c") | Some("cpp") | Some("cc") | Some("cxx") | Some("h") | Some("hpp") => {
342-
self.detectors.iter().map(|d| d.as_ref()).collect()
343-
}
344-
Some("go") => self.detectors.iter().map(|d| d.as_ref()).collect(),
345-
Some("php") => self.detectors.iter().map(|d| d.as_ref()).collect(),
346-
Some("rb") => self.detectors.iter().map(|d| d.as_ref()).collect(),
347-
Some("sh") | Some("bash") | Some("zsh") => {
340+
Some("sh" | "bash" | "zsh") => self.detectors.iter().map(|d| d.as_ref()).collect(),
341+
Some("json" | "yaml" | "yml" | "toml" | "xml" | "ini" | "cfg") => {
348342
self.detectors.iter().map(|d| d.as_ref()).collect()
349343
}
350-
Some("json") | Some("yaml") | Some("yml") | Some("toml") | Some("xml")
351-
| Some("ini") | Some("cfg") => self.detectors.iter().map(|d| d.as_ref()).collect(),
352344
_ => self.detectors.iter().map(|d| d.as_ref()).collect(),
353345
}
354346
}
@@ -546,22 +538,18 @@ impl AdvancedScanner {
546538

547539
match ext {
548540
Some("rs") => self.detectors.iter().map(|d| d.as_ref()).collect(),
549-
Some("js") | Some("ts") | Some("jsx") | Some("tsx") | Some("vue") | Some("svelte") => {
550-
self.detectors.iter().map(|d| d.as_ref()).collect()
551-
}
552-
Some("py") | Some("pyw") | Some("pyx") => {
541+
Some("js" | "ts" | "jsx" | "tsx" | "vue" | "svelte") => {
553542
self.detectors.iter().map(|d| d.as_ref()).collect()
554543
}
544+
Some("py" | "pyw" | "pyx") => self.detectors.iter().map(|d| d.as_ref()).collect(),
555545
Some("java") => self.detectors.iter().map(|d| d.as_ref()).collect(),
556-
Some("c") | Some("cpp") | Some("cc") | Some("cxx") | Some("h") | Some("hpp") => {
546+
Some("c" | "cpp" | "cc" | "cxx" | "h" | "hpp") => {
557547
self.detectors.iter().map(|d| d.as_ref()).collect()
558548
}
559549
Some("go") => self.detectors.iter().map(|d| d.as_ref()).collect(),
560550
Some("php") => self.detectors.iter().map(|d| d.as_ref()).collect(),
561551
Some("rb") => self.detectors.iter().map(|d| d.as_ref()).collect(),
562-
Some("sh") | Some("bash") | Some("zsh") => {
563-
self.detectors.iter().map(|d| d.as_ref()).collect()
564-
}
552+
Some("sh" | "bash" | "zsh") => self.detectors.iter().map(|d| d.as_ref()).collect(),
565553
Some("json") | Some("yaml") | Some("yml") | Some("toml") | Some("xml")
566554
| Some("ini") | Some("cfg") => self.detectors.iter().map(|d| d.as_ref()).collect(),
567555
_ => self.detectors.iter().map(|d| d.as_ref()).collect(),

0 commit comments

Comments
 (0)