Skip to content

Commit e75111c

Browse files
committed
refactor: simplify sorting, pattern matching, and line iteration logic across distillers and pipeline modules
1 parent 8f4cbde commit e75111c

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

src/distillers/jsts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn distill_tsc(input: &str) -> String {
294294

295295
let mut sorted: Vec<(String, Vec<String>)> = by_file.into_iter().collect();
296296
// Sort by number of errors descending
297-
sorted.sort_by(|a, b| b.1.len().cmp(&a.1.len()));
297+
sorted.sort_by_key(|a| std::cmp::Reverse(a.1.len()));
298298

299299
for (file, issues) in sorted.iter().take(5) {
300300
let count = issues.len();

src/pipeline/registry.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ pub fn resolve_profile(command: &str) -> ToolProfile {
3434
let parts: Vec<&str> = cmd_lower.split_whitespace().collect();
3535
let sub = parts.get(1).copied().unwrap_or("");
3636
match sub {
37-
"diff" | "show" | "whatchanged" => {
38-
if !cmd_lower.contains("--stat") {
39-
return ToolProfile {
40-
segmentation: SegmentationMode::GitHunk,
41-
collapse: CollapseMode::Generic,
42-
};
43-
}
37+
"diff" | "show" | "whatchanged" if !cmd_lower.contains("--stat") => {
38+
return ToolProfile {
39+
segmentation: SegmentationMode::GitHunk,
40+
collapse: CollapseMode::Generic,
41+
};
4442
}
4543
_ => {}
4644
}

src/pipeline/scorer.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,8 @@ pub fn score_segments(
243243
}
244244
SegmentationMode::Line => {
245245
// Segment per line
246-
let mut line_num = 1;
247246
let mut boost_counter = 0;
248-
for line in input.lines() {
247+
for (line_num, line) in (1..).zip(input.lines()) {
249248
let mut tier = classify_line(line);
250249

251250
if tier == SignalTier::Critical {
@@ -272,7 +271,6 @@ pub fn score_segments(
272271
context_score,
273272
line_range: (line_num, line_num),
274273
});
275-
line_num += 1;
276274
}
277275
}
278276
}

0 commit comments

Comments
 (0)