Skip to content

Commit a4fbff1

Browse files
committed
fix CI formatter check
1 parent d113ce2 commit a4fbff1

File tree

5 files changed

+41
-34
lines changed

5 files changed

+41
-34
lines changed

crates/diff-engine/src/changes.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,13 @@ impl ChangeClassifier {
513513
.collect(),
514514
});
515515

516-
if name_similarity > self.config.rename_threshold {
517-
if primary_type != ChangeType::Rename {
518-
alternatives.push(AlternativeClassification {
519-
change_type: ChangeType::Rename,
520-
confidence: name_similarity,
521-
reason: "High name similarity suggests rename".to_string(),
522-
});
523-
}
516+
if name_similarity > self.config.rename_threshold && primary_type != ChangeType::Rename
517+
{
518+
alternatives.push(AlternativeClassification {
519+
change_type: ChangeType::Rename,
520+
confidence: name_similarity,
521+
reason: "High name similarity suggests rename".to_string(),
522+
});
524523
}
525524
}
526525

@@ -770,11 +769,11 @@ impl ChangeClassifier {
770769
let mut matrix = vec![vec![0; len2 + 1]; len1 + 1];
771770

772771
// Initialize first row and column
773-
for i in 0..=len1 {
774-
matrix[i][0] = i;
772+
for (i, row) in matrix.iter_mut().enumerate().take(len1 + 1) {
773+
row[0] = i;
775774
}
776-
for j in 0..=len2 {
777-
matrix[0][j] = j;
775+
for (j, cell) in matrix[0].iter_mut().enumerate().take(len2 + 1) {
776+
*cell = j;
778777
}
779778

780779
let s1_chars: Vec<char> = s1.chars().collect();
@@ -871,31 +870,31 @@ impl ChangeClassifier {
871870

872871
/// Calculate AST complexity
873872
fn calculate_ast_complexity(&self, ast: &ASTNode) -> f64 {
874-
let node_count = self.count_ast_nodes(ast) as f64;
875-
let depth = self.calculate_ast_depth(ast) as f64;
873+
let node_count = Self::count_ast_nodes(ast) as f64;
874+
let depth = Self::calculate_ast_depth(ast) as f64;
876875

877876
// Simple complexity metric based on size and depth
878877
(node_count * 0.7) + (depth * 0.3)
879878
}
880879

881880
/// Count nodes in AST
882-
fn count_ast_nodes(&self, ast: &ASTNode) -> usize {
881+
fn count_ast_nodes(ast: &ASTNode) -> usize {
883882
1 + ast
884883
.children
885884
.iter()
886-
.map(|child| self.count_ast_nodes(child))
885+
.map(|child| Self::count_ast_nodes(child))
887886
.sum::<usize>()
888887
}
889888

890889
/// Calculate AST depth
891-
fn calculate_ast_depth(&self, ast: &ASTNode) -> usize {
890+
fn calculate_ast_depth(ast: &ASTNode) -> usize {
892891
if ast.children.is_empty() {
893892
1
894893
} else {
895894
1 + ast
896895
.children
897896
.iter()
898-
.map(|child| self.calculate_ast_depth(child))
897+
.map(|child| Self::calculate_ast_depth(child))
899898
.max()
900899
.unwrap_or(0)
901900
}

crates/diff-engine/src/cross_file_tracker.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,12 @@ pub struct CrossFileTrackingStats {
188188

189189
impl CrossFileTracker {
190190
pub fn new(language: Language, config: CrossFileTrackerConfig) -> Self {
191-
let mut hungarian_config = HungarianMatcherConfig::default();
192-
hungarian_config.enable_cross_file_matching = true;
193-
hungarian_config.cross_file_penalty = config.cross_file_move_penalty;
194-
hungarian_config.min_similarity_threshold = config.min_cross_file_similarity;
191+
let hungarian_config = HungarianMatcherConfig {
192+
enable_cross_file_matching: true,
193+
cross_file_penalty: config.cross_file_move_penalty,
194+
min_similarity_threshold: config.min_cross_file_similarity,
195+
..Default::default()
196+
};
195197

196198
let hungarian_matcher = HungarianMatcher::new(language, hungarian_config);
197199
let similarity_scorer = SimilarityScorer::with_defaults(language);
@@ -279,6 +281,7 @@ impl CrossFileTracker {
279281

280282
Ok(result)
281283
}
284+
#[allow(clippy::type_complexity)]
282285

283286
/// Identify functions that are unmatched within their original files
284287
fn identify_unmatched_functions(

crates/diff-engine/src/graph_matcher.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl Default for GraphMatcherConfig {
5757
pub struct GraphMatcher {
5858
config: GraphMatcherConfig,
5959
similarity_scorer: SimilarityScorer,
60+
#[allow(dead_code)]
6061
language: Language,
6162
}
6263

crates/diff-engine/src/smart_matcher.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! handle same-named functions, simple functions, and cross-file moves.
66
77
use smart_diff_parser::{Change, ChangeType, CodeElement, Function, MatchResult};
8-
use std::collections::{HashMap, HashSet};
8+
use std::collections::HashSet;
99

1010
/// Configuration for smart matching
1111
#[derive(Debug, Clone)]
@@ -209,7 +209,7 @@ impl SmartMatcher {
209209
score += body_weight * body_sim;
210210
weight += body_weight;
211211

212-
let mut final_score = if weight > 0.0 { score / weight } else { 0.0 };
212+
let final_score = if weight > 0.0 { score / weight } else { 0.0 };
213213

214214
// Rule 3a: Stricter matching for different-named functions
215215
// If names are different, require high body similarity to avoid matching
@@ -227,7 +227,7 @@ impl SmartMatcher {
227227
return 0.0;
228228
}
229229
// For moderately similar names (0.5-0.8), require 92% body similarity
230-
if name_sim >= 0.5 && name_sim < 0.8 && body_sim < 0.92 {
230+
if (0.5..0.8).contains(&name_sim) && body_sim < 0.92 {
231231
return 0.0;
232232
}
233233
// For very different names (< 0.5), require 95% body similarity
@@ -249,18 +249,18 @@ impl SmartMatcher {
249249
/// Check if a function is "simple" (small body, likely a getter/setter/wrapper)
250250
fn is_simple_function(&self, func: &Function) -> bool {
251251
// Count non-empty nodes in the body
252-
let node_count = self.count_ast_nodes(&func.body);
252+
let node_count = Self::count_ast_nodes(&func.body);
253253
// Simple functions: single statement wrappers, getters, setters
254254
// Typically have 10 or fewer AST nodes
255255
node_count <= 10
256256
}
257257

258258
/// Count AST nodes recursively
259-
fn count_ast_nodes(&self, node: &smart_diff_parser::ASTNode) -> usize {
259+
fn count_ast_nodes(node: &smart_diff_parser::ASTNode) -> usize {
260260
1 + node
261261
.children
262262
.iter()
263-
.map(|child| self.count_ast_nodes(child))
263+
.map(|child| Self::count_ast_nodes(child))
264264
.sum::<usize>()
265265
}
266266

@@ -271,11 +271,11 @@ impl SmartMatcher {
271271
body2: &smart_diff_parser::ASTNode,
272272
) -> f64 {
273273
// Simple structural similarity based on node count and depth
274-
let count1 = self.count_ast_nodes(body1);
275-
let count2 = self.count_ast_nodes(body2);
274+
let count1 = Self::count_ast_nodes(body1);
275+
let count2 = Self::count_ast_nodes(body2);
276276

277-
let depth1 = self.calculate_ast_depth(body1);
278-
let depth2 = self.calculate_ast_depth(body2);
277+
let depth1 = Self::calculate_ast_depth(body1);
278+
let depth2 = Self::calculate_ast_depth(body2);
279279

280280
// Node count similarity (60%)
281281
let count_sim = if count1.max(count2) == 0 {
@@ -301,14 +301,14 @@ impl SmartMatcher {
301301
}
302302

303303
/// Calculate AST depth
304-
fn calculate_ast_depth(&self, node: &smart_diff_parser::ASTNode) -> usize {
304+
fn calculate_ast_depth(node: &smart_diff_parser::ASTNode) -> usize {
305305
if node.children.is_empty() {
306306
1
307307
} else {
308308
1 + node
309309
.children
310310
.iter()
311-
.map(|child| self.calculate_ast_depth(child))
311+
.map(|child| Self::calculate_ast_depth(child))
312312
.max()
313313
.unwrap_or(0)
314314
}

crates/diff-engine/src/tree_edit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ impl TreeEditDistance {
193193
}
194194

195195
/// Check if two trees are structurally identical
196+
#[allow(clippy::only_used_in_recursion)]
196197
fn are_trees_identical(&self, tree1: &ASTNode, tree2: &ASTNode) -> bool {
197198
if tree1.node_type != tree2.node_type {
198199
return false;
@@ -271,6 +272,7 @@ impl TreeEditDistance {
271272
}
272273

273274
/// Recursively hash tree structure
275+
#[allow(clippy::only_used_in_recursion)]
274276
fn hash_tree_recursive(
275277
&self,
276278
tree: &ASTNode,
@@ -569,6 +571,7 @@ impl TreeEditDistance {
569571
}
570572

571573
/// Count total nodes in tree
574+
#[allow(clippy::only_used_in_recursion)]
572575
fn count_nodes(&self, tree: &ASTNode) -> usize {
573576
1 + tree
574577
.children
@@ -578,6 +581,7 @@ impl TreeEditDistance {
578581
}
579582

580583
/// Calculate tree depth
584+
#[allow(clippy::only_used_in_recursion)]
581585
fn calculate_depth(&self, tree: &ASTNode) -> usize {
582586
if tree.children.is_empty() {
583587
1

0 commit comments

Comments
 (0)