Skip to content

Commit 37f2bb6

Browse files
committed
clippy fix
1 parent 7104369 commit 37f2bb6

File tree

7 files changed

+34
-41
lines changed

7 files changed

+34
-41
lines changed

build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn main() {
4141
for lang in languages.values() {
4242
for ext in &lang.extensions {
4343
let ext = ext.trim_start_matches('.');
44-
code.push_str(&format!(" set.insert(\"{}\");\n", ext));
44+
code.push_str(&format!(" set.insert(\"{ext}\");\n"));
4545
}
4646
}
4747

@@ -54,7 +54,7 @@ fn main() {
5454

5555
for lang in languages.values() {
5656
for filename in &lang.filenames {
57-
code.push_str(&format!(" set.insert(\"{}\");\n", filename));
57+
code.push_str(&format!(" set.insert(\"{filename}\");\n"));
5858
}
5959
}
6060

@@ -67,7 +67,7 @@ fn main() {
6767

6868
for lang in languages.values() {
6969
for interpreter in &lang.interpreters {
70-
code.push_str(&format!(" set.insert(\"{}\");\n", interpreter));
70+
code.push_str(&format!(" set.insert(\"{interpreter}\");\n"));
7171
}
7272
}
7373

src/analyzer.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn process_entries(args: &Cli) -> Result<Vec<FileEntry>> {
100100
for pattern in includes {
101101
// Include patterns are positive patterns (no ! prefix)
102102
if let Err(e) = override_builder.add(pattern) {
103-
eprintln!("Warning: Invalid include pattern '{}': {}", pattern, e);
103+
eprintln!("Warning: Invalid include pattern '{pattern}': {e}");
104104
}
105105
}
106106
}
@@ -113,15 +113,14 @@ pub fn process_entries(args: &Cli) -> Result<Vec<FileEntry>> {
113113
// Add a '!' prefix if it doesn't already have one
114114
// This makes it a negative pattern (exclude)
115115
let exclude_pattern = if !pattern.starts_with('!') {
116-
format!("!{}", pattern)
116+
format!("!{pattern}")
117117
} else {
118118
pattern.clone()
119119
};
120120

121121
if let Err(e) = override_builder.add(&exclude_pattern) {
122122
eprintln!(
123-
"Warning: Invalid exclude pattern '{}': {}",
124-
pattern, e
123+
"Warning: Invalid exclude pattern '{pattern}': {e}"
125124
);
126125
}
127126
}
@@ -149,8 +148,7 @@ pub fn process_entries(args: &Cli) -> Result<Vec<FileEntry>> {
149148
let pattern = format!("!{}", file_path.display());
150149
if let Err(e) = override_builder.add(&pattern) {
151150
eprintln!(
152-
"Warning: Could not add file exclude pattern '{}': {}",
153-
pattern, e
151+
"Warning: Could not add file exclude pattern '{pattern}': {e}"
154152
);
155153
}
156154
}
@@ -195,7 +193,7 @@ pub fn process_entries(args: &Cli) -> Result<Vec<FileEntry>> {
195193
for pattern in includes {
196194
// Include patterns are positive patterns (no ! prefix)
197195
if let Err(e) = override_builder.add(pattern) {
198-
eprintln!("Warning: Invalid include pattern '{}': {}", pattern, e);
196+
eprintln!("Warning: Invalid include pattern '{pattern}': {e}");
199197
}
200198
}
201199
}
@@ -208,14 +206,13 @@ pub fn process_entries(args: &Cli) -> Result<Vec<FileEntry>> {
208206
// Add a '!' prefix if it doesn't already have one
209207
// This makes it a negative pattern (exclude)
210208
let exclude_pattern = if !pattern.starts_with('!') {
211-
format!("!{}", pattern)
209+
format!("!{pattern}")
212210
} else {
213211
pattern.clone()
214212
};
215213
if let Err(e) = override_builder.add(&exclude_pattern) {
216214
eprintln!(
217-
"Warning: Invalid exclude pattern '{}': {}",
218-
pattern, e
215+
"Warning: Invalid exclude pattern '{pattern}': {e}"
219216
);
220217
}
221218
}
@@ -336,7 +333,7 @@ mod tests {
336333
fs::create_dir_all(parent)?;
337334
}
338335
let mut file = File::create(&full_path)?;
339-
writeln!(file, "{}", content)?;
336+
writeln!(file, "{content}")?;
340337
created_files.push(full_path);
341338
}
342339

@@ -393,7 +390,7 @@ mod tests {
393390
// For patterns that should exclude, we need to add a "!" prefix
394391
// to make them negative patterns (exclusions)
395392
let exclude_pattern = if !pattern.starts_with('!') {
396-
format!("!{}", pattern)
393+
format!("!{pattern}")
397394
} else {
398395
pattern.clone()
399396
};
@@ -419,8 +416,7 @@ mod tests {
419416

420417
assert_eq!(
421418
is_ignored, should_exclude,
422-
"Failed for exclude: {:?}",
423-
exclude
419+
"Failed for exclude: {exclude:?}"
424420
);
425421
}
426422

@@ -587,12 +583,12 @@ mod tests {
587583

588584
// Test with depth limit of 1
589585
cli.max_depth = Some(1);
590-
let _ = process_directory(&cli)?;
586+
process_directory(&cli)?;
591587
// Verify only top-level files were processed
592588

593589
// Test with depth limit of 2
594590
cli.max_depth = Some(2);
595-
let _ = process_directory(&cli)?;
591+
process_directory(&cli)?;
596592
// Verify files up to depth 2 were processed
597593

598594
Ok(())
@@ -605,12 +601,12 @@ mod tests {
605601

606602
// Test without hidden files
607603
cli.hidden = false;
608-
let _ = process_directory(&cli)?;
604+
process_directory(&cli)?;
609605
// Verify hidden files were not processed
610606

611607
// Test with hidden files
612608
cli.hidden = true;
613-
let _ = process_directory(&cli)?;
609+
process_directory(&cli)?;
614610
// Verify hidden files were processed
615611

616612
Ok(())
@@ -622,7 +618,7 @@ mod tests {
622618
let rust_file = files.iter().find(|f| f.ends_with("main.rs")).unwrap();
623619

624620
let cli = create_test_cli(rust_file);
625-
let _ = process_directory(&cli)?;
621+
process_directory(&cli)?;
626622
// Verify single file was processed correctly
627623

628624
Ok(())

src/git_processor.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,14 @@ mod tests {
8181
for url in valid_urls {
8282
assert!(
8383
GitProcessor::is_git_url(url),
84-
"URL should be valid: {}",
85-
url
84+
"URL should be valid: {url}"
8685
);
8786
}
8887

8988
for url in invalid_urls {
9089
assert!(
9190
!GitProcessor::is_git_url(url),
92-
"URL should be invalid: {}",
93-
url
91+
"URL should be invalid: {url}"
9492
);
9593
}
9694
}
@@ -136,11 +134,11 @@ mod tests {
136134
let parsed_url = Url::parse(url).unwrap();
137135
let repo_name = parsed_url
138136
.path_segments()
139-
.and_then(|segments| segments.last())
137+
.and_then(|mut segments| segments.next_back())
140138
.map(|name| name.trim_end_matches(".git"))
141139
.unwrap_or("repo");
142140

143-
assert_eq!(repo_name, expected_name, "Failed for URL: {}", url);
141+
assert_eq!(repo_name, expected_name, "Failed for URL: {url}");
144142
}
145143
}
146144

@@ -155,7 +153,7 @@ mod tests {
155153
// Check for some common files that should be present
156154
assert!(path.join("Cargo.toml").exists(), "Cargo.toml should exist");
157155
}
158-
Err(e) => println!("Skipping clone test due to error: {}", e),
156+
Err(e) => println!("Skipping clone test due to error: {e}"),
159157
}
160158
}
161159
}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn main() -> anyhow::Result<()> {
168168
fs::write(output_file, content)?;
169169
println!("Output written to: {}", output_file.display());
170170
} else if args.print {
171-
println!("{}", content);
171+
println!("{content}");
172172
} else {
173173
// Default behavior for URLs if no -f or --print: copy to clipboard
174174
match arboard::Clipboard::new()

src/output.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn try_copy_with_osc52(content: &str) -> Result<(), Box<dyn std::error::Error>>
143143
pub fn handle_output(content: String, args: &Cli) -> Result<()> {
144144
// Print to stdout if no other output method is specified
145145
if args.print {
146-
println!("{}", content);
146+
println!("{content}");
147147
}
148148

149149
// Copy to clipboard if requested
@@ -153,7 +153,7 @@ pub fn handle_output(content: String, args: &Cli) -> Result<()> {
153153
Err(_) => {
154154
match try_copy_with_osc52(&content) {
155155
Ok(_) => println!("Context prepared! (using terminal clipboard) Paste into your LLM of choice + Profit."),
156-
Err(e) => eprintln!("Warning: Failed to copy to clipboard: {}. Output will continue with other specified formats.", e)
156+
Err(e) => eprintln!("Warning: Failed to copy to clipboard: {e}. Output will continue with other specified formats.")
157157
}
158158
},
159159
}

src/source_detection.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ mod tests {
121121
assert_eq!(
122122
extract_interpreter(input).as_deref(),
123123
expected,
124-
"Failed for input: {}",
125-
input
124+
"Failed for input: {input}"
126125
);
127126
}
128127
}
@@ -151,7 +150,7 @@ mod tests {
151150
for (name, content, expected) in test_cases {
152151
let path = dir.path().join(name);
153152
let mut file = File::create(&path).unwrap();
154-
writeln!(file, "{}", content).unwrap();
153+
writeln!(file, "{content}").unwrap();
155154

156155
assert_eq!(
157156
is_source_file(&path),

src/url_processor.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl UrlProcessor {
2929
.template("{spinner:.green} {msg}")
3030
.unwrap(),
3131
);
32-
pb.set_message(format!("Processing {}", url));
32+
pb.set_message(format!("Processing {url}"));
3333

3434
let content = self.fetch_url(&url)?;
3535
let mut markdown = self.html_to_markdown(&content, &url);
@@ -39,18 +39,18 @@ impl UrlProcessor {
3939
for link in links {
4040
if !self.visited.contains(&link) {
4141
self.visited.insert(link.clone());
42-
pb.set_message(format!("Processing sublink: {}", link));
42+
pb.set_message(format!("Processing sublink: {link}"));
4343
let mut sub_processor = UrlProcessor::new(self.max_depth - 1);
4444
if let Ok(sub_content) = sub_processor.process_url(&link, true) {
4545
markdown.push_str("\n\n---\n\n");
46-
markdown.push_str(&format!("## Content from {}\n\n", link));
46+
markdown.push_str(&format!("## Content from {link}\n\n"));
4747
markdown.push_str(&sub_content);
4848
}
4949
}
5050
}
5151
}
5252

53-
pb.finish_with_message(format!("Finished processing {}", url));
53+
pb.finish_with_message(format!("Finished processing {url}"));
5454

5555
if let Ok(mut clipboard) = Clipboard::new() {
5656
let _ = clipboard.set_text(&markdown);
@@ -156,9 +156,9 @@ impl UrlProcessor {
156156
}
157157
let link_text = link_text.trim();
158158
if link_text.is_empty() {
159-
output.push_str(&format!("[{}]({})", href, href));
159+
output.push_str(&format!("[{href}]({href})"));
160160
} else {
161-
output.push_str(&format!("[{}]({})", link_text, href));
161+
output.push_str(&format!("[{link_text}]({href})"));
162162
}
163163
}
164164
}

0 commit comments

Comments
 (0)