Skip to content

Commit dcf68e4

Browse files
Alex HolmbergAlex Holmberg
authored andcommitted
feat: fixed fmt / clappy issues in ci pipeline
1 parent 846d4e4 commit dcf68e4

18 files changed

Lines changed: 548 additions & 500 deletions

File tree

src/agent/persistence.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,11 @@ impl SessionSelector {
252252

253253
// Try to parse as numeric index first
254254
if let Ok(index) = identifier.parse::<usize>()
255-
&& index > 0 && index <= sessions.len() {
256-
return sessions.into_iter().nth(index - 1);
257-
}
255+
&& index > 0
256+
&& index <= sessions.len()
257+
{
258+
return sessions.into_iter().nth(index - 1);
259+
}
258260

259261
// Try to find by UUID or partial UUID
260262
sessions

src/agent/tools/fetch.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,33 @@ impl WebFetchTool {
7171
// Try to fetch robots.txt (ignore errors - many sites don't have one)
7272
if let Ok(response) = self.client().get(&robots_url).send().await
7373
&& response.status().is_success()
74-
&& let Ok(robots_content) = response.text().await {
75-
let path = url.path();
76-
for line in robots_content.lines() {
77-
if let Some(disallowed) = line.strip_prefix("Disallow: ") {
78-
let disallowed = disallowed.trim();
79-
if !disallowed.is_empty() {
80-
let disallowed = if !disallowed.starts_with('/') {
81-
format!("/{}", disallowed)
82-
} else {
83-
disallowed.to_string()
84-
};
85-
let check_path = if !path.starts_with('/') {
86-
format!("/{}", path)
87-
} else {
88-
path.to_string()
89-
};
90-
if check_path.starts_with(&disallowed) {
91-
return Err(WebFetchError(format!(
92-
"URL {} cannot be fetched due to robots.txt restrictions",
93-
url
94-
)));
95-
}
96-
}
74+
&& let Ok(robots_content) = response.text().await
75+
{
76+
let path = url.path();
77+
for line in robots_content.lines() {
78+
if let Some(disallowed) = line.strip_prefix("Disallow: ") {
79+
let disallowed = disallowed.trim();
80+
if !disallowed.is_empty() {
81+
let disallowed = if !disallowed.starts_with('/') {
82+
format!("/{}", disallowed)
83+
} else {
84+
disallowed.to_string()
85+
};
86+
let check_path = if !path.starts_with('/') {
87+
format!("/{}", path)
88+
} else {
89+
path.to_string()
90+
};
91+
if check_path.starts_with(&disallowed) {
92+
return Err(WebFetchError(format!(
93+
"URL {} cannot be fetched due to robots.txt restrictions",
94+
url
95+
)));
9796
}
9897
}
9998
}
99+
}
100+
}
100101
Ok(())
101102
}
102103

src/agent/ui/hooks.rs

Lines changed: 112 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,47 +1194,48 @@ fn format_kubelint_result(
11941194

11951195
// Check for parse errors first
11961196
if let Some(errors) = parse_errors
1197-
&& !errors.is_empty() {
1198-
lines.push(format!(
1199-
"{}☸ {} parse error{} (files could not be fully analyzed){}",
1200-
ansi::HIGH,
1201-
errors.len(),
1202-
if errors.len() == 1 { "" } else { "s" },
1203-
ansi::RESET
1204-
));
1205-
for (i, err) in errors.iter().take(3).enumerate() {
1206-
if let Some(err_str) = err.as_str() {
1207-
let truncated = if err_str.len() > 70 {
1208-
format!("{}...", &err_str[..67])
1209-
} else {
1210-
err_str.to_string()
1211-
};
1212-
lines.push(format!(
1213-
"{} {} {}{}",
1214-
ansi::HIGH,
1215-
if i == errors.len().min(3) - 1 {
1216-
"└"
1217-
} else {
1218-
"│"
1219-
},
1220-
truncated,
1221-
ansi::RESET
1222-
));
1223-
}
1224-
}
1225-
if errors.len() > 3 {
1197+
&& !errors.is_empty()
1198+
{
1199+
lines.push(format!(
1200+
"{}☸ {} parse error{} (files could not be fully analyzed){}",
1201+
ansi::HIGH,
1202+
errors.len(),
1203+
if errors.len() == 1 { "" } else { "s" },
1204+
ansi::RESET
1205+
));
1206+
for (i, err) in errors.iter().take(3).enumerate() {
1207+
if let Some(err_str) = err.as_str() {
1208+
let truncated = if err_str.len() > 70 {
1209+
format!("{}...", &err_str[..67])
1210+
} else {
1211+
err_str.to_string()
1212+
};
12261213
lines.push(format!(
1227-
"{} +{} more errors{}",
1228-
ansi::GRAY,
1229-
errors.len() - 3,
1214+
"{} {} {}{}",
1215+
ansi::HIGH,
1216+
if i == errors.len().min(3) - 1 {
1217+
"└"
1218+
} else {
1219+
"│"
1220+
},
1221+
truncated,
12301222
ansi::RESET
12311223
));
12321224
}
1233-
// If we only have parse errors and no lint issues, return early
1234-
if total == 0 {
1235-
return (false, lines);
1236-
}
12371225
}
1226+
if errors.len() > 3 {
1227+
lines.push(format!(
1228+
"{} +{} more errors{}",
1229+
ansi::GRAY,
1230+
errors.len() - 3,
1231+
ansi::RESET
1232+
));
1233+
}
1234+
// If we only have parse errors and no lint issues, return early
1235+
if total == 0 {
1236+
return (false, lines);
1237+
}
1238+
}
12381239

12391240
if total == 0 && parse_errors.map(|e| e.is_empty()).unwrap_or(true) {
12401241
lines.push(format!(
@@ -1329,28 +1330,29 @@ fn format_kubelint_result(
13291330
&& let Some(high_issues) = action_plan
13301331
.and_then(|a| a.get("high"))
13311332
.and_then(|h| h.as_array())
1332-
{
1333-
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1334-
lines.push(format_kubelint_issue(issue, "🟠", ansi::HIGH));
1335-
shown += 1;
1336-
}
1333+
{
1334+
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1335+
lines.push(format_kubelint_issue(issue, "🟠", ansi::HIGH));
1336+
shown += 1;
13371337
}
1338+
}
13381339

13391340
// Show quick fix hint
13401341
if let Some(quick_fixes) = v.get("quick_fixes").and_then(|q| q.as_array())
1341-
&& let Some(first_fix) = quick_fixes.first().and_then(|f| f.as_str()) {
1342-
let truncated = if first_fix.len() > 70 {
1343-
format!("{}...", &first_fix[..67])
1344-
} else {
1345-
first_fix.to_string()
1346-
};
1347-
lines.push(format!(
1348-
"{} → Fix: {}{}",
1349-
ansi::INFO_BLUE,
1350-
truncated,
1351-
ansi::RESET
1352-
));
1353-
}
1342+
&& let Some(first_fix) = quick_fixes.first().and_then(|f| f.as_str())
1343+
{
1344+
let truncated = if first_fix.len() > 70 {
1345+
format!("{}...", &first_fix[..67])
1346+
} else {
1347+
first_fix.to_string()
1348+
};
1349+
lines.push(format!(
1350+
"{} → Fix: {}{}",
1351+
ansi::INFO_BLUE,
1352+
truncated,
1353+
ansi::RESET
1354+
));
1355+
}
13541356

13551357
// Note about remaining issues
13561358
let remaining = total as usize - shown;
@@ -1427,47 +1429,48 @@ fn format_helmlint_result(
14271429

14281430
// Check for parse errors first
14291431
if let Some(errors) = parse_errors
1430-
&& !errors.is_empty() {
1431-
lines.push(format!(
1432-
"{}⎈ {} parse error{} (chart could not be fully analyzed){}",
1433-
ansi::HIGH,
1434-
errors.len(),
1435-
if errors.len() == 1 { "" } else { "s" },
1436-
ansi::RESET
1437-
));
1438-
for (i, err) in errors.iter().take(3).enumerate() {
1439-
if let Some(err_str) = err.as_str() {
1440-
let truncated = if err_str.len() > 70 {
1441-
format!("{}...", &err_str[..67])
1442-
} else {
1443-
err_str.to_string()
1444-
};
1445-
lines.push(format!(
1446-
"{} {} {}{}",
1447-
ansi::HIGH,
1448-
if i == errors.len().min(3) - 1 {
1449-
"└"
1450-
} else {
1451-
"│"
1452-
},
1453-
truncated,
1454-
ansi::RESET
1455-
));
1456-
}
1457-
}
1458-
if errors.len() > 3 {
1432+
&& !errors.is_empty()
1433+
{
1434+
lines.push(format!(
1435+
"{}⎈ {} parse error{} (chart could not be fully analyzed){}",
1436+
ansi::HIGH,
1437+
errors.len(),
1438+
if errors.len() == 1 { "" } else { "s" },
1439+
ansi::RESET
1440+
));
1441+
for (i, err) in errors.iter().take(3).enumerate() {
1442+
if let Some(err_str) = err.as_str() {
1443+
let truncated = if err_str.len() > 70 {
1444+
format!("{}...", &err_str[..67])
1445+
} else {
1446+
err_str.to_string()
1447+
};
14591448
lines.push(format!(
1460-
"{} +{} more errors{}",
1461-
ansi::GRAY,
1462-
errors.len() - 3,
1449+
"{} {} {}{}",
1450+
ansi::HIGH,
1451+
if i == errors.len().min(3) - 1 {
1452+
"└"
1453+
} else {
1454+
"│"
1455+
},
1456+
truncated,
14631457
ansi::RESET
14641458
));
14651459
}
1466-
// If we only have parse errors and no lint issues, return early
1467-
if total == 0 {
1468-
return (false, lines);
1469-
}
14701460
}
1461+
if errors.len() > 3 {
1462+
lines.push(format!(
1463+
"{} +{} more errors{}",
1464+
ansi::GRAY,
1465+
errors.len() - 3,
1466+
ansi::RESET
1467+
));
1468+
}
1469+
// If we only have parse errors and no lint issues, return early
1470+
if total == 0 {
1471+
return (false, lines);
1472+
}
1473+
}
14711474

14721475
if total == 0 && parse_errors.map(|e| e.is_empty()).unwrap_or(true) {
14731476
lines.push(format!(
@@ -1562,28 +1565,29 @@ fn format_helmlint_result(
15621565
&& let Some(high_issues) = action_plan
15631566
.and_then(|a| a.get("high"))
15641567
.and_then(|h| h.as_array())
1565-
{
1566-
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1567-
lines.push(format_helmlint_issue(issue, "🟠", ansi::HIGH));
1568-
shown += 1;
1569-
}
1568+
{
1569+
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1570+
lines.push(format_helmlint_issue(issue, "🟠", ansi::HIGH));
1571+
shown += 1;
15701572
}
1573+
}
15711574

15721575
// Show quick fix hint
15731576
if let Some(quick_fixes) = v.get("quick_fixes").and_then(|q| q.as_array())
1574-
&& let Some(first_fix) = quick_fixes.first().and_then(|f| f.as_str()) {
1575-
let truncated = if first_fix.len() > 70 {
1576-
format!("{}...", &first_fix[..67])
1577-
} else {
1578-
first_fix.to_string()
1579-
};
1580-
lines.push(format!(
1581-
"{} → Fix: {}{}",
1582-
ansi::INFO_BLUE,
1583-
truncated,
1584-
ansi::RESET
1585-
));
1586-
}
1577+
&& let Some(first_fix) = quick_fixes.first().and_then(|f| f.as_str())
1578+
{
1579+
let truncated = if first_fix.len() > 70 {
1580+
format!("{}...", &first_fix[..67])
1581+
} else {
1582+
first_fix.to_string()
1583+
};
1584+
lines.push(format!(
1585+
"{} → Fix: {}{}",
1586+
ansi::INFO_BLUE,
1587+
truncated,
1588+
ansi::RESET
1589+
));
1590+
}
15871591

15881592
// Note about remaining issues
15891593
let remaining = total as usize - shown;

src/analyzer/helmlint/lint.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ fn collect_chart_files(path: &Path) -> HashSet<String> {
316316
.filter_map(|e| e.ok())
317317
{
318318
if entry.path().is_file()
319-
&& let Ok(relative) = entry.path().strip_prefix(path) {
320-
files.insert(relative.display().to_string());
321-
}
319+
&& let Ok(relative) = entry.path().strip_prefix(path)
320+
{
321+
files.insert(relative.display().to_string());
322+
}
322323
}
323324

324325
files

src/analyzer/helmlint/pragma.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ impl PragmaState {
3939

4040
// Check if the rule is ignored for this specific line
4141
if let Some(ignores) = self.line_ignores.get(&line)
42-
&& ignores.contains(code.as_str()) {
43-
return true;
44-
}
42+
&& ignores.contains(code.as_str())
43+
{
44+
return true;
45+
}
4546

4647
// Check if previous line has an ignore pragma for this line
4748
if line > 1
4849
&& let Some(ignores) = self.line_ignores.get(&(line - 1))
49-
&& ignores.contains(code.as_str()) {
50-
return true;
51-
}
50+
&& ignores.contains(code.as_str())
51+
{
52+
return true;
53+
}
5254

5355
false
5456
}

0 commit comments

Comments
 (0)