Skip to content

Commit c0dfef6

Browse files
authored
Merge pull request #263 from syncable-dev/develop
Develop
2 parents cb0c453 + dcf68e4 commit c0dfef6

21 files changed

Lines changed: 595 additions & 605 deletions

.DS_Store

0 Bytes
Binary file not shown.

src/agent/persistence.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,11 @@ impl SessionSelector {
251251
let sessions = self.list_sessions();
252252

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

260261
// Try to find by UUID or partial UUID

src/agent/tools/fetch.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,30 @@ impl WebFetchTool {
6969
let robots_url = format!("{}://{}/robots.txt", url.scheme(), url.authority());
7070

7171
// Try to fetch robots.txt (ignore errors - many sites don't have one)
72-
if let Ok(response) = self.client().get(&robots_url).send().await {
73-
if response.status().is_success() {
74-
if 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-
}
72+
if let Ok(response) = self.client().get(&robots_url).send().await
73+
&& response.status().is_success()
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
}

src/agent/ui/hooks.rs

Lines changed: 114 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,47 +1193,47 @@ fn format_kubelint_result(
11931193
let mut lines = Vec::new();
11941194

11951195
// Check for parse errors first
1196-
if let Some(errors) = parse_errors {
1197-
if !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 {
1196+
if let Some(errors) = parse_errors
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-
}
1225+
}
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);
12371237
}
12381238
}
12391239

@@ -1326,33 +1326,32 @@ fn format_kubelint_result(
13261326
}
13271327

13281328
// Then high priority
1329-
if shown < MAX_PREVIEW {
1330-
if let Some(high_issues) = action_plan
1329+
if shown < MAX_PREVIEW
1330+
&& let Some(high_issues) = action_plan
13311331
.and_then(|a| a.get("high"))
13321332
.and_then(|h| h.as_array())
1333-
{
1334-
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1335-
lines.push(format_kubelint_issue(issue, "🟠", ansi::HIGH));
1336-
shown += 1;
1337-
}
1333+
{
1334+
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1335+
lines.push(format_kubelint_issue(issue, "🟠", ansi::HIGH));
1336+
shown += 1;
13381337
}
13391338
}
13401339

13411340
// Show quick fix hint
1342-
if let Some(quick_fixes) = v.get("quick_fixes").and_then(|q| q.as_array()) {
1343-
if let Some(first_fix) = quick_fixes.first().and_then(|f| f.as_str()) {
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-
}
1341+
if let Some(quick_fixes) = v.get("quick_fixes").and_then(|q| q.as_array())
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+
));
13561355
}
13571356

13581357
// Note about remaining issues
@@ -1429,47 +1428,47 @@ fn format_helmlint_result(
14291428
let mut lines = Vec::new();
14301429

14311430
// Check for parse errors first
1432-
if let Some(errors) = parse_errors {
1433-
if !errors.is_empty() {
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-
};
1448-
lines.push(format!(
1449-
"{} {} {}{}",
1450-
ansi::HIGH,
1451-
if i == errors.len().min(3) - 1 {
1452-
"└"
1453-
} else {
1454-
"│"
1455-
},
1456-
truncated,
1457-
ansi::RESET
1458-
));
1459-
}
1460-
}
1461-
if errors.len() > 3 {
1431+
if let Some(errors) = parse_errors
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+
};
14621448
lines.push(format!(
1463-
"{} +{} more errors{}",
1464-
ansi::GRAY,
1465-
errors.len() - 3,
1449+
"{} {} {}{}",
1450+
ansi::HIGH,
1451+
if i == errors.len().min(3) - 1 {
1452+
"└"
1453+
} else {
1454+
"│"
1455+
},
1456+
truncated,
14661457
ansi::RESET
14671458
));
14681459
}
1469-
// If we only have parse errors and no lint issues, return early
1470-
if total == 0 {
1471-
return (false, lines);
1472-
}
1460+
}
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);
14731472
}
14741473
}
14751474

@@ -1562,33 +1561,32 @@ fn format_helmlint_result(
15621561
}
15631562

15641563
// Then high priority
1565-
if shown < MAX_PREVIEW {
1566-
if let Some(high_issues) = action_plan
1564+
if shown < MAX_PREVIEW
1565+
&& let Some(high_issues) = action_plan
15671566
.and_then(|a| a.get("high"))
15681567
.and_then(|h| h.as_array())
1569-
{
1570-
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1571-
lines.push(format_helmlint_issue(issue, "🟠", ansi::HIGH));
1572-
shown += 1;
1573-
}
1568+
{
1569+
for issue in high_issues.iter().take(MAX_PREVIEW - shown) {
1570+
lines.push(format_helmlint_issue(issue, "🟠", ansi::HIGH));
1571+
shown += 1;
15741572
}
15751573
}
15761574

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

15941592
// Note about remaining issues

src/analyzer/helmlint/lint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ fn collect_chart_files(path: &Path) -> HashSet<String> {
315315
.into_iter()
316316
.filter_map(|e| e.ok())
317317
{
318-
if entry.path().is_file() {
319-
if let Ok(relative) = entry.path().strip_prefix(path) {
320-
files.insert(relative.display().to_string());
321-
}
318+
if entry.path().is_file()
319+
&& let Ok(relative) = entry.path().strip_prefix(path)
320+
{
321+
files.insert(relative.display().to_string());
322322
}
323323
}
324324

src/analyzer/helmlint/pragma.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ impl PragmaState {
3838
}
3939

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

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

5655
false

0 commit comments

Comments
 (0)