Skip to content

Commit 283a12b

Browse files
Alex Holmbergclaude
authored andcommitted
style: fix print_with_newline clippy lint and format code
- Change print!(...\n) to println!(...) in spinner.rs - Apply cargo fmt formatting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e4baffd commit 283a12b

28 files changed

Lines changed: 153 additions & 164 deletions

File tree

src/agent/commands.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,7 @@ fn show_simple_picker(picker: &CommandPicker) -> Option<String> {
597597
println!();
598598

599599
for (i, cmd) in picker.filtered_commands.iter().enumerate() {
600-
print!(
601-
" [{}] {}/{:<12}",
602-
i + 1,
603-
ansi::PURPLE,
604-
cmd.name
605-
);
600+
print!(" [{}] {}/{:<12}", i + 1, ansi::PURPLE, cmd.name);
606601
if let Some(alias) = cmd.alias {
607602
print!(" ({})", alias);
608603
}

src/agent/compact/summary.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,7 @@ pub fn extract_assistant_action(response: &str, max_len: usize) -> String {
314314
let response = response.trim();
315315

316316
// Take first sentence or line
317-
let first_part = response
318-
.split(['.', '\n'])
319-
.next()
320-
.unwrap_or(response);
317+
let first_part = response.split(['.', '\n']).next().unwrap_or(response);
321318

322319
truncate(first_part, max_len)
323320
}

src/agent/ide/client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,11 @@ impl IdeClient {
568568
let total_errors = diagnostics
569569
.iter()
570570
.filter(|d| d.severity == DiagnosticSeverity::Error)
571-
.count()
572-
as u32;
571+
.count() as u32;
573572
let total_warnings = diagnostics
574573
.iter()
575574
.filter(|d| d.severity == DiagnosticSeverity::Warning)
576-
.count()
577-
as u32;
575+
.count() as u32;
578576
return Ok(DiagnosticsResponse {
579577
diagnostics,
580578
total_errors,

src/agent/tools/file_ops.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,8 @@ The tool will create parent directories automatically if they don't exist."#.to_
643643
&& let Some(parent) = file_path.parent()
644644
&& !parent.exists()
645645
{
646-
fs::create_dir_all(parent).map_err(|e| {
647-
WriteFileError(format!("Failed to create directories: {}", e))
648-
})?;
646+
fs::create_dir_all(parent)
647+
.map_err(|e| WriteFileError(format!("Failed to create directories: {}", e)))?;
649648
}
650649

651650
// Check if file exists (for reporting)

src/agent/ui/spinner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async fn run_spinner(
194194
if has_printed_tool_line {
195195
// Move up to tool line, update it, move back down to spinner line
196196
if let Some(ref tool) = current_tool {
197-
print!("{}{} {}🔧 {}{}\n", // Move back down
197+
println!("{}{} {}🔧 {}{}", // Move back down
198198
ansi::CURSOR_UP,
199199
ansi::CLEAR_LINE,
200200
ansi::PURPLE,

src/analyzer/context/language_analyzers/python.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ pub(crate) fn analyze_python_project(
4949
(script_cap.get(1), script_cap.get(2), script_cap.get(3))
5050
{
5151
entry_points.push(EntryPoint {
52-
file: PathBuf::from(format!(
53-
"{}.py",
54-
module.as_str().replace('.', "/")
55-
)),
52+
file: PathBuf::from(format!("{}.py", module.as_str().replace('.', "/"))),
5653
function: Some(func.as_str().to_string()),
5754
command: Some(name.as_str().to_string()),
5855
});

src/analyzer/dclint/formatter/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,7 @@ mod tests {
220220
fn test_output_format_from_str() {
221221
assert_eq!(OutputFormat::parse("json"), Some(OutputFormat::Json));
222222
assert_eq!(OutputFormat::parse("JSON"), Some(OutputFormat::Json));
223-
assert_eq!(
224-
OutputFormat::parse("stylish"),
225-
Some(OutputFormat::Stylish)
226-
);
223+
assert_eq!(OutputFormat::parse("stylish"), Some(OutputFormat::Stylish));
227224
assert_eq!(OutputFormat::parse("github"), Some(OutputFormat::GitHub));
228225
assert_eq!(OutputFormat::parse("invalid"), None);
229226
}

src/analyzer/dclint/types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ impl fmt::Display for Severity {
5555
}
5656
}
5757

58-
5958
impl Ord for Severity {
6059
fn cmp(&self, other: &Self) -> Ordering {
6160
// Higher severity = lower numeric value for Ord
@@ -301,7 +300,6 @@ impl ConfigLevel {
301300
}
302301
}
303302

304-
305303
#[cfg(test)]
306304
mod tests {
307305
use super::*;

src/analyzer/dependency_parser.rs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ impl DependencyParser {
261261
name: name.to_string(),
262262
version: version.to_string(),
263263
dep_type,
264-
license: detect_rust_license(name)
265-
.unwrap_or_else(|| "Unknown".to_string()),
264+
license: detect_rust_license(name).unwrap_or_else(|| "Unknown".to_string()),
266265
source: Some("crates.io".to_string()),
267266
language: Language::Rust,
268267
});
@@ -352,7 +351,9 @@ impl DependencyParser {
352351
// Parse regular dependencies
353352
if let Some(dependencies) = parsed.get("dependencies").and_then(|d| d.as_object()) {
354353
for (name, version) in dependencies {
355-
let Some(ver_str) = version.as_str() else { continue };
354+
let Some(ver_str) = version.as_str() else {
355+
continue;
356+
};
356357
deps.push(DependencyInfo {
357358
name: name.clone(),
358359
version: ver_str.to_string(),
@@ -367,7 +368,9 @@ impl DependencyParser {
367368
// Parse dev dependencies
368369
if let Some(dev_deps) = parsed.get("devDependencies").and_then(|d| d.as_object()) {
369370
for (name, version) in dev_deps {
370-
let Some(ver_str) = version.as_str() else { continue };
371+
let Some(ver_str) = version.as_str() else {
372+
continue;
373+
};
371374
deps.push(DependencyInfo {
372375
name: name.clone(),
373376
version: ver_str.to_string(),
@@ -455,7 +458,9 @@ impl DependencyParser {
455458
{
456459
debug!("Found PEP 621 dependencies in pyproject.toml");
457460
for dep in project_deps {
458-
let Some(dep_str) = dep.as_str() else { continue };
461+
let Some(dep_str) = dep.as_str() else {
462+
continue;
463+
};
459464
let (name, version) = self.parse_python_requirement_spec(dep_str);
460465
deps.push(DependencyInfo {
461466
name: name.clone(),
@@ -477,10 +482,14 @@ impl DependencyParser {
477482
{
478483
debug!("Found PEP 621 optional dependencies in pyproject.toml");
479484
for (group_name, group_deps) in optional_deps {
480-
let Some(deps_array) = group_deps.as_array() else { continue };
485+
let Some(deps_array) = group_deps.as_array() else {
486+
continue;
487+
};
481488
let is_dev = group_name.contains("dev") || group_name.contains("test");
482489
for dep in deps_array {
483-
let Some(dep_str) = dep.as_str() else { continue };
490+
let Some(dep_str) = dep.as_str() else {
491+
continue;
492+
};
484493
let (name, version) = self.parse_python_requirement_spec(dep_str);
485494
deps.push(DependencyInfo {
486495
name: name.clone(),
@@ -508,9 +517,13 @@ impl DependencyParser {
508517
{
509518
debug!("Found PDM dev dependencies in pyproject.toml");
510519
for (_group_name, group_deps) in pdm_deps {
511-
let Some(deps_array) = group_deps.as_array() else { continue };
520+
let Some(deps_array) = group_deps.as_array() else {
521+
continue;
522+
};
512523
for dep in deps_array {
513-
let Some(dep_str) = dep.as_str() else { continue };
524+
let Some(dep_str) = dep.as_str() else {
525+
continue;
526+
};
514527
let (name, version) = self.parse_python_requirement_spec(dep_str);
515528
deps.push(DependencyInfo {
516529
name: name.clone(),
@@ -535,7 +548,9 @@ impl DependencyParser {
535548
{
536549
debug!("Found setuptools dependencies in pyproject.toml");
537550
for dep in setuptools_deps {
538-
let Some(dep_str) = dep.as_str() else { continue };
551+
let Some(dep_str) = dep.as_str() else {
552+
continue;
553+
};
539554
let (name, version) = self.parse_python_requirement_spec(dep_str);
540555
deps.push(DependencyInfo {
541556
name: name.clone(),
@@ -1097,9 +1112,7 @@ impl DependencyParser {
10971112
|| trimmed.starts_with("testImplementation ")
10981113
|| trimmed.starts_with("testCompile ");
10991114

1100-
if is_dependency
1101-
&& let Some(dep_str) = extract_gradle_dependency(trimmed)
1102-
{
1115+
if is_dependency && let Some(dep_str) = extract_gradle_dependency(trimmed) {
11031116
let parts: Vec<&str> = dep_str.split(':').collect();
11041117
if parts.len() >= 3 {
11051118
let group_id = parts[0];
@@ -1723,9 +1736,7 @@ fn parse_jvm_dependencies(project_root: &Path) -> Result<DependencyMap> {
17231736
|| trimmed.starts_with("testImplementation")
17241737
|| trimmed.starts_with("testCompile");
17251738

1726-
if is_dep
1727-
&& let Some(dep_str) = extract_gradle_dependency(trimmed)
1728-
{
1739+
if is_dep && let Some(dep_str) = extract_gradle_dependency(trimmed) {
17291740
let parts: Vec<&str> = dep_str.split(':').collect();
17301741
if parts.len() >= 3 {
17311742
let name = format!("{}:{}", parts[0], parts[1]);
@@ -1809,9 +1820,7 @@ fn parse_jvm_dependencies_detailed(project_root: &Path) -> Result<DetailedDepend
18091820
|| trimmed.starts_with("testImplementation")
18101821
|| trimmed.starts_with("testCompile");
18111822

1812-
if is_dep
1813-
&& let Some(dep_str) = extract_gradle_dependency(trimmed)
1814-
{
1823+
if is_dep && let Some(dep_str) = extract_gradle_dependency(trimmed) {
18151824
let parts: Vec<&str> = dep_str.split(':').collect();
18161825
if parts.len() >= 3 {
18171826
let name = format!("{}:{}", parts[0], parts[1]);

src/analyzer/display/helpers.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,7 @@ pub fn display_technologies_detailed_legacy(technologies: &[DetectedTechnology])
153153
std::collections::HashMap::new();
154154

155155
for tech in technologies {
156-
by_category
157-
.entry(&tech.category)
158-
.or_default()
159-
.push(tech);
156+
by_category.entry(&tech.category).or_default().push(tech);
160157
}
161158

162159
// Find and display primary technology
@@ -229,8 +226,7 @@ pub fn display_technologies_detailed_legacy(technologies: &[DetectedTechnology])
229226
};
230227

231228
// Only print if not already handled above
232-
if !matches!(lib_type, LibraryType::UI | LibraryType::Utility) && !techs.is_empty()
233-
{
229+
if !matches!(lib_type, LibraryType::UI | LibraryType::Utility) && !techs.is_empty() {
234230
println!("\n {}:", label);
235231
for tech in techs {
236232
println!(
@@ -258,10 +254,7 @@ pub fn display_technologies_detailed_legacy_to_string(
258254
std::collections::HashMap::new();
259255

260256
for tech in technologies {
261-
by_category
262-
.entry(&tech.category)
263-
.or_default()
264-
.push(tech);
257+
by_category.entry(&tech.category).or_default().push(tech);
265258
}
266259

267260
// Find and display primary technology
@@ -334,8 +327,7 @@ pub fn display_technologies_detailed_legacy_to_string(
334327
};
335328

336329
// Only print if not already handled above
337-
if !matches!(lib_type, LibraryType::UI | LibraryType::Utility) && !techs.is_empty()
338-
{
330+
if !matches!(lib_type, LibraryType::UI | LibraryType::Utility) && !techs.is_empty() {
339331
output.push_str(&format!("\n {}:\n", label));
340332
for tech in techs {
341333
output.push_str(&format!(

0 commit comments

Comments
 (0)