From f2f8a3abaf701e8752762d0e53d464c17b8b61f8 Mon Sep 17 00:00:00 2001 From: Marlon Costa Date: Mon, 19 Jan 2026 19:52:20 -0300 Subject: [PATCH 1/4] fix: Address clippy collapsible_if warnings with let-chains Convert nested if-let statements to let-chains (Rust 2024 edition feature) for cleaner control flow. Files modified: - rust-code-analysis-cli/src/main.rs: preproc_lock handling - src/alterator.rs: CppCode PreprocDef newline handling - src/checker.rs: RustCode is_useful_comment check - src/find.rs: Find callback file printing - src/getter.rs: PythonCode string handling, CppCode function name extraction --- rust-code-analysis-cli/src/main.rs | 18 +++++------ src/alterator.rs | 8 ++--- src/checker.rs | 10 +++---- src/find.rs | 14 ++++----- src/getter.rs | 48 +++++++++++++++--------------- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/rust-code-analysis-cli/src/main.rs b/rust-code-analysis-cli/src/main.rs index 4e9c0da43..728029297 100644 --- a/rust-code-analysis-cli/src/main.rs +++ b/rust-code-analysis-cli/src/main.rs @@ -139,15 +139,15 @@ fn act_on_file(path: PathBuf, cfg: &Config) -> std::io::Result<()> { }; action::(&language, source, &path, pr, cfg) } else if cfg.preproc_lock.is_some() { - if let Some(language) = guess_language(&source, &path).0 { - if language == LANG::Cpp { - let mut results = cfg.preproc_lock.as_ref().unwrap().lock().unwrap(); - preprocess( - &PreprocParser::new(source, &path, None), - &path, - &mut results, - ); - } + if let Some(language) = guess_language(&source, &path).0 + && language == LANG::Cpp + { + let mut results = cfg.preproc_lock.as_ref().unwrap().lock().unwrap(); + preprocess( + &PreprocParser::new(source, &path, None), + &path, + &mut results, + ); } Ok(()) } else { diff --git a/src/alterator.rs b/src/alterator.rs index 6e9f9734f..a79c4964a 100644 --- a/src/alterator.rs +++ b/src/alterator.rs @@ -70,10 +70,10 @@ impl Alterator for CppCode { AstNode::new(node.kind(), text, span, Vec::new()) } Cpp::PreprocDef | Cpp::PreprocFunctionDef | Cpp::PreprocCall => { - if let Some(last) = children.last() { - if last.r#type == "\n" { - children.pop(); - } + if let Some(last) = children.last() + && last.r#type == "\n" + { + children.pop(); } Self::get_default(node, code, span, children) } diff --git a/src/checker.rs b/src/checker.rs index 75c433b82..ec965b993 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -601,11 +601,11 @@ impl Checker for RustCode { } fn is_useful_comment(node: &Node, code: &[u8]) -> bool { - if let Some(parent) = node.parent() { - if parent.kind_id() == Rust::TokenTree { - // A comment could be a macro token - return true; - } + if let Some(parent) = node.parent() + && parent.kind_id() == Rust::TokenTree + { + // A comment could be a macro token + return true; } let code = &code[node.start_byte()..node.end_byte()]; code.starts_with(b"/// cbindgen:") diff --git a/src/find.rs b/src/find.rs index f441fe533..b6c37b91c 100644 --- a/src/find.rs +++ b/src/find.rs @@ -65,14 +65,14 @@ impl Callback for Find { type Cfg = FindCfg; fn call(cfg: Self::Cfg, parser: &T) -> Self::Res { - if let Some(good) = find(parser, &cfg.filters) { - if !good.is_empty() { - println!("In file {}", cfg.path.to_str().unwrap()); - for node in good { - dump_node(parser.get_code(), &node, 1, cfg.line_start, cfg.line_end)?; - } - println!(); + if let Some(good) = find(parser, &cfg.filters) + && !good.is_empty() + { + println!("In file {}", cfg.path.to_str().unwrap()); + for node in good { + dump_node(parser.get_code(), &node, 1, cfg.line_start, cfg.line_end)?; } + println!(); } Ok(()) } diff --git a/src/getter.rs b/src/getter.rs index 8a03adc50..74ca4f0e8 100644 --- a/src/getter.rs +++ b/src/getter.rs @@ -75,11 +75,11 @@ impl Getter for PythonCode { String => { let mut operator = HalsteadType::Unknown; // check if we've a documentation string or a multiline comment - if let Some(parent) = node.parent() { - if parent.kind_id() != ExpressionStatement || parent.child_count() != 1 { - operator = HalsteadType::Operand; - }; - } + if let Some(parent) = node.parent() + && (parent.kind_id() != ExpressionStatement || parent.child_count() != 1) + { + operator = HalsteadType::Operand; + }; operator } _ => HalsteadType::Unknown, @@ -444,28 +444,28 @@ impl Getter for CppCode { Cpp::FunctionDeclarator == id || Cpp::FunctionDeclarator2 == id || Cpp::FunctionDeclarator3 == id - }) { - if let Some(first) = fd.child(0) { - match first.kind_id().into() { - Cpp::TypeIdentifier - | Cpp::Identifier - | Cpp::FieldIdentifier - | Cpp::DestructorName - | Cpp::OperatorName - | Cpp::QualifiedIdentifier - | Cpp::QualifiedIdentifier2 - | Cpp::QualifiedIdentifier3 - | Cpp::QualifiedIdentifier4 - | Cpp::TemplateFunction - | Cpp::TemplateMethod => { - let code = &code[first.start_byte()..first.end_byte()]; - return std::str::from_utf8(code).ok(); - } - _ => {} - } + }) + && let Some(first) = fd.child(0) + { + match first.kind_id().into() { + Cpp::TypeIdentifier + | Cpp::Identifier + | Cpp::FieldIdentifier + | Cpp::DestructorName + | Cpp::OperatorName + | Cpp::QualifiedIdentifier + | Cpp::QualifiedIdentifier2 + | Cpp::QualifiedIdentifier3 + | Cpp::QualifiedIdentifier4 + | Cpp::TemplateFunction + | Cpp::TemplateMethod => { + let code = &code[first.start_byte()..first.end_byte()]; + return std::str::from_utf8(code).ok(); } + _ => {} } } + } } _ => { if let Some(name) = node.child_by_field_name("name") { From 8b64267becd3946be201e95be72621c0eaf954ee Mon Sep 17 00:00:00 2001 From: Marlon Costa Date: Mon, 19 Jan 2026 20:34:00 -0300 Subject: [PATCH 2/4] fix: Address all clippy warnings with let-chains and lifetime annotations - Fix collapsible_if warnings using Rust 2024 let-chains syntax - Add explicit lifetime annotations to resolve mismatched_lifetime_syntaxes warnings - Remove unnecessary parentheses in closure body - Fix formatting issues in getter.rs Files modified: - src/tools.rs: Remove unnecessary parentheses - src/node.rs: Add lifetime annotations, collapse nested if statements - src/traits.rs: Add lifetime annotation to get_root signature - src/parser.rs: Add lifetime annotation to get_root implementation - src/getter.rs: Fix formatting of let-chains - src/metrics/abc.rs: Collapse nested if statements (8 occurrences) - src/metrics/cognitive.rs: Collapse nested if statement - src/metrics/loc.rs: Collapse nested if statement - src/metrics/nargs.rs: Collapse nested if statement --- .../affected-repos.txt | 2 + .../edited-files.log | 87 +++++++++++++++++++ .gitignore | 1 + src/getter.rs | 37 ++++---- src/metrics/abc.rs | 74 ++++++++-------- src/metrics/cognitive.rs | 8 +- src/metrics/loc.rs | 13 +-- src/metrics/nargs.rs | 10 +-- src/node.rs | 20 ++--- src/parser.rs | 2 +- src/tools.rs | 2 +- src/traits.rs | 2 +- 12 files changed, 174 insertions(+), 84 deletions(-) create mode 100644 .claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt create mode 100644 .claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log diff --git a/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt b/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt new file mode 100644 index 000000000..830455972 --- /dev/null +++ b/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt @@ -0,0 +1,2 @@ +root +src diff --git a/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log b/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log new file mode 100644 index 000000000..26b6f2405 --- /dev/null +++ b/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log @@ -0,0 +1,87 @@ +1768840242:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840302:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840387:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840388:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840418:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840419:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840540:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840541:/tmp/rca-fork-1768837625/Cargo.toml:root +1768840850:/tmp/rca-fork-1768837625/.gitignore:root +1768842340:/tmp/rca-fork-1768837625/src/node.rs:src +1768842438:/tmp/rca-fork-1768837625/src/traits.rs:src +1768842448:/tmp/rca-fork-1768837625/src/node.rs:src +1768842459:/tmp/rca-fork-1768837625/src/node.rs:src +1768842473:/tmp/rca-fork-1768837625/src/node.rs:src +1768843128:/tmp/rca-fork-1768837625/src/asttools.rs:src +1768843150:/tmp/rca-fork-1768837625/src/lib.rs:src +1768843290:/tmp/rca-fork-1768837625/src/metrics/npa.rs:src +1768843308:/tmp/rca-fork-1768837625/src/metrics/npm.rs:src +1768843431:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768843438:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768843443:/tmp/rca-fork-1768837625/src/metrics/cognitive.rs:src +1768843959:/tmp/rca-fork-1768837625/src/asttools.rs:src +1768843960:/tmp/rca-fork-1768837625/src/getter.rs:src +1768843961:/tmp/rca-fork-1768837625/src/getter.rs:src +1768843962:/tmp/rca-fork-1768837625/src/alterator.rs:src +1768843997:/tmp/rca-fork-1768837625/src/node.rs:src +1768844004:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768844041:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768844044:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768844073:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768844093:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768844094:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768844149:/tmp/rca-fork-1768837625/src/metrics/cognitive.rs:src +1768844151:/tmp/rca-fork-1768837625/src/metrics/loc.rs:src +1768844152:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src +1768844154:/tmp/rca-fork-1768837625/src/checker.rs:src +1768844156:/tmp/rca-fork-1768837625/src/find.rs:src +1768844379:/tmp/rca-fork-1768837625/src/checker.rs:src +1768844381:/tmp/rca-fork-1768837625/src/checker.rs:src +1768844383:/tmp/rca-fork-1768837625/src/concurrent_files.rs:src +1768844402:/tmp/rca-fork-1768837625/src/concurrent_files.rs:src +1768845153:/tmp/rca-fork-1768837625/Cargo.toml:root +1768858484:/tmp/rca-fork-1768837625/Cargo.toml:root +1768858580:/tmp/rca-fork-1768837625/src/node.rs:src +1768859149:/tmp/rca-fork-1768837625/src/macros.rs:src +1768859200:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src +1768859210:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src +1768859465:/tmp/rca-fork-1768837625/Cargo.toml:root +1768859497:/tmp/rca-fork-1768837625/src/langs.rs:src +1768859514:/tmp/rca-fork-1768837625/src/macros.rs:src +1768861425:/tmp/rca-fork-1768837625/src/lib.rs:src +1768861527:/tmp/rca-fork-1768837625/src/node.rs:src +1768862461:/tmp/rca-fork-1768837625/src/node.rs:src +1768862667:/tmp/rca-fork-1768837625/src/node.rs:src +1768863000:/tmp/rca-fork-1768837625/src/alterator.rs:src +1768863006:/tmp/rca-fork-1768837625/src/checker.rs:src +1768863013:/tmp/rca-fork-1768837625/src/find.rs:src +1768863031:/tmp/rca-fork-1768837625/src/getter.rs:src +1768863044:/tmp/rca-fork-1768837625/src/getter.rs:src +1768863057:/tmp/rca-fork-1768837625/src/getter.rs:src +1768863086:/tmp/rca-fork-1768837625/src/getter.rs:src +1768863233:/tmp/rca-fork-1768837625/Cargo.toml:root +1768863309:/tmp/rca-fork-1768837625/src/node.rs:src +1768864437:/tmp/rca-fork-1768837625/src/node.rs:src +1768864441:/tmp/rca-fork-1768837625/src/node.rs:src +1768864444:/tmp/rca-fork-1768837625/src/traits.rs:src +1768864446:/tmp/rca-fork-1768837625/src/parser.rs:src +1768864987:/tmp/rca-fork-1768837625/src/tools.rs:src +1768864995:/tmp/rca-fork-1768837625/src/node.rs:src +1768864996:/tmp/rca-fork-1768837625/src/node.rs:src +1768865009:/tmp/rca-fork-1768837625/src/node.rs:src +1768865526:/tmp/rca-fork-1768837625/src/tools.rs:src +1768865527:/tmp/rca-fork-1768837625/src/node.rs:src +1768865529:/tmp/rca-fork-1768837625/src/node.rs:src +1768865531:/tmp/rca-fork-1768837625/src/node.rs:src +1768865532:/tmp/rca-fork-1768837625/src/traits.rs:src +1768865534:/tmp/rca-fork-1768837625/src/parser.rs:src +1768865557:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768865559:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768865560:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768865561:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768865563:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768865564:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768865567:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src +1768865582:/tmp/rca-fork-1768837625/src/metrics/cognitive.rs:src +1768865584:/tmp/rca-fork-1768837625/src/metrics/loc.rs:src +1768865586:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src diff --git a/.gitignore b/.gitignore index 97dc21d31..4732d5498 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target enums/target *~ Cargo.lock +.claude/ diff --git a/src/getter.rs b/src/getter.rs index 74ca4f0e8..c4cc4fc86 100644 --- a/src/getter.rs +++ b/src/getter.rs @@ -444,28 +444,27 @@ impl Getter for CppCode { Cpp::FunctionDeclarator == id || Cpp::FunctionDeclarator2 == id || Cpp::FunctionDeclarator3 == id - }) - && let Some(first) = fd.child(0) - { - match first.kind_id().into() { - Cpp::TypeIdentifier - | Cpp::Identifier - | Cpp::FieldIdentifier - | Cpp::DestructorName - | Cpp::OperatorName - | Cpp::QualifiedIdentifier - | Cpp::QualifiedIdentifier2 - | Cpp::QualifiedIdentifier3 - | Cpp::QualifiedIdentifier4 - | Cpp::TemplateFunction - | Cpp::TemplateMethod => { - let code = &code[first.start_byte()..first.end_byte()]; - return std::str::from_utf8(code).ok(); + }) && let Some(first) = fd.child(0) + { + match first.kind_id().into() { + Cpp::TypeIdentifier + | Cpp::Identifier + | Cpp::FieldIdentifier + | Cpp::DestructorName + | Cpp::OperatorName + | Cpp::QualifiedIdentifier + | Cpp::QualifiedIdentifier2 + | Cpp::QualifiedIdentifier3 + | Cpp::QualifiedIdentifier4 + | Cpp::TemplateFunction + | Cpp::TemplateMethod => { + let code = &code[first.start_byte()..first.end_byte()]; + return std::str::from_utf8(code).ok(); + } + _ => {} } - _ => {} } } - } } _ => { if let Some(name) = node.child_by_field_name("name") { diff --git a/src/metrics/abc.rs b/src/metrics/abc.rs index 2a1e62a89..a147a4792 100644 --- a/src/metrics/abc.rs +++ b/src/metrics/abc.rs @@ -404,10 +404,10 @@ impl Abc for JavaCode { } GT | LT => { // Excludes `<` and `>` used for generic types - if let Some(parent) = node.parent() { - if !matches!(parent.kind_id().into(), TypeArguments) { - stats.conditions += 1.; - } + if let Some(parent) = node.parent() + && !matches!(parent.kind_id().into(), TypeArguments) + { + stats.conditions += 1.; } } // Counts unary conditions in elements separated by `&&` or `||` boolean operators @@ -423,31 +423,31 @@ impl Abc for JavaCode { // Counts unary conditions inside assignments VariableDeclarator | AssignmentExpression => { // The child node of index 2 contains the right operand of an assignment operation - if let Some(right_operand) = node.child(2) { - if matches!( + if let Some(right_operand) = node.child(2) + && matches!( right_operand.kind_id().into(), ParenthesizedExpression | UnaryExpression - ) { - java_inspect_container(&right_operand, &mut stats.conditions); - } + ) + { + java_inspect_container(&right_operand, &mut stats.conditions); } } // Counts unary conditions inside if and while statements IfStatement | WhileStatement => { // The child node of index 1 contains the condition - if let Some(condition) = node.child(1) { - if matches!(condition.kind_id().into(), ParenthesizedExpression) { - java_inspect_container(&condition, &mut stats.conditions); - } + if let Some(condition) = node.child(1) + && matches!(condition.kind_id().into(), ParenthesizedExpression) + { + java_inspect_container(&condition, &mut stats.conditions); } } // Counts unary conditions do-while statements DoStatement => { // The child node of index 3 contains the condition - if let Some(condition) = node.child(3) { - if matches!(condition.kind_id().into(), ParenthesizedExpression) { - java_inspect_container(&condition, &mut stats.conditions); - } + if let Some(condition) = node.child(3) + && matches!(condition.kind_id().into(), ParenthesizedExpression) + { + java_inspect_container(&condition, &mut stats.conditions); } } // Counts unary conditions inside for statements @@ -487,25 +487,25 @@ impl Abc for JavaCode { // Counts unary conditions inside return statements ReturnStatement => { // The child node of index 1 contains the return value - if let Some(value) = node.child(1) { - if matches!( + if let Some(value) = node.child(1) + && matches!( value.kind_id().into(), ParenthesizedExpression | UnaryExpression - ) { - java_inspect_container(&value, &mut stats.conditions) - } + ) + { + java_inspect_container(&value, &mut stats.conditions) } } // Counts unary conditions inside implicit return statements in lambda expressions LambdaExpression => { // The child node of index 2 contains the return value - if let Some(value) = node.child(2) { - if matches!( + if let Some(value) = node.child(2) + && matches!( value.kind_id().into(), ParenthesizedExpression | UnaryExpression - ) { - java_inspect_container(&value, &mut stats.conditions) - } + ) + { + java_inspect_container(&value, &mut stats.conditions) } } // Counts unary conditions inside ternary expressions @@ -523,22 +523,22 @@ impl Abc for JavaCode { } } // The child node of index 2 contains the first expression - if let Some(expression) = node.child(2) { - if matches!( + if let Some(expression) = node.child(2) + && matches!( expression.kind_id().into(), ParenthesizedExpression | UnaryExpression - ) { - java_inspect_container(&expression, &mut stats.conditions); - } + ) + { + java_inspect_container(&expression, &mut stats.conditions); } // The child node of index 4 contains the second expression - if let Some(expression) = node.child(4) { - if matches!( + if let Some(expression) = node.child(4) + && matches!( expression.kind_id().into(), ParenthesizedExpression | UnaryExpression - ) { - java_inspect_container(&expression, &mut stats.conditions); - } + ) + { + java_inspect_container(&expression, &mut stats.conditions); } } _ => {} diff --git a/src/metrics/cognitive.rs b/src/metrics/cognitive.rs index a7b09fea3..4a619cade 100644 --- a/src/metrics/cognitive.rs +++ b/src/metrics/cognitive.rs @@ -328,10 +328,10 @@ impl Cognitive for RustCode { increment_by_one(stats); } BreakExpression | ContinueExpression => { - if let Some(label_child) = node.child(1) { - if let Label = label_child.kind_id().into() { - increment_by_one(stats); - } + if let Some(label_child) = node.child(1) + && let Label = label_child.kind_id().into() + { + increment_by_one(stats); } } UnaryExpression => { diff --git a/src/metrics/loc.rs b/src/metrics/loc.rs index d081ab489..5a422598d 100644 --- a/src/metrics/loc.rs +++ b/src/metrics/loc.rs @@ -553,12 +553,13 @@ fn add_cloc_lines(stats: &mut Stats, start: usize, end: usize) { // This difference is necessary in order to avoid having // a wrong count for the blank metric. fn check_comment_ends_on_code_line(stats: &mut Stats, start_code_line: usize) { - if let Some(end) = stats.cloc.comment_line_end { - if end == start_code_line && !stats.ploc.lines.contains(&start_code_line) { - // Comment entirely *before* a code line - stats.cloc.only_comment_lines -= 1; - stats.cloc.code_comment_lines += 1; - } + if let Some(end) = stats.cloc.comment_line_end + && end == start_code_line + && !stats.ploc.lines.contains(&start_code_line) + { + // Comment entirely *before* a code line + stats.cloc.only_comment_lines -= 1; + stats.cloc.code_comment_lines += 1; } } diff --git a/src/metrics/nargs.rs b/src/metrics/nargs.rs index 9df9a66af..ce531f6e6 100644 --- a/src/metrics/nargs.rs +++ b/src/metrics/nargs.rs @@ -220,11 +220,11 @@ impl NArgs for CppCode { return; } - if Self::is_closure(node) { - if let Some(declarator) = node.child_by_field_name("declarator") { - let new_node = declarator; - compute_args::(&new_node, &mut stats.closure_nargs); - } + if Self::is_closure(node) + && let Some(declarator) = node.child_by_field_name("declarator") + { + let new_node = declarator; + compute_args::(&new_node, &mut stats.closure_nargs); } } } diff --git a/src/node.rs b/src/node.rs index f6b98bb15..0cfc8171a 100644 --- a/src/node.rs +++ b/src/node.rs @@ -18,7 +18,7 @@ impl Tree { Self(parser.parse(code, None).unwrap()) } - pub(crate) fn get_root(&self) -> Node { + pub(crate) fn get_root(&self) -> Node<'_> { Node(self.0.root_node()) } } @@ -108,7 +108,7 @@ impl<'a> Node<'a> { self.0.child_count() } - pub(crate) fn child_by_field_name(&self, name: &str) -> Option { + pub(crate) fn child_by_field_name(&self, name: &str) -> Option> { self.0.child_by_field_name(name).map(Node) } @@ -168,15 +168,15 @@ impl<'a> Node<'a> { pub(crate) fn has_ancestors(&self, typ: fn(&Node) -> bool, typs: fn(&Node) -> bool) -> bool { let mut res = false; let mut node = *self; - if let Some(parent) = node.parent() { - if typ(&parent) { - node = parent; - } + if let Some(parent) = node.parent() + && typ(&parent) + { + node = parent; } - if let Some(parent) = node.parent() { - if typs(&parent) { - res = true; - } + if let Some(parent) = node.parent() + && typs(&parent) + { + res = true; } res } diff --git a/src/parser.rs b/src/parser.rs index 6973247e4..b13901fb8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -152,7 +152,7 @@ impl< } #[inline(always)] - fn get_root(&self) -> Node { + fn get_root(&self) -> Node<'_> { self.tree.get_root() } diff --git a/src/tools.rs b/src/tools.rs index 2dd1cf7d9..17d6f9869 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -250,7 +250,7 @@ pub(crate) fn remove_blank_lines(data: &mut Vec) { let count_trailing = data .iter() .rev() - .take_while(|&c| (*c == b'\n' || *c == b'\r')) + .take_while(|&c| *c == b'\n' || *c == b'\r') .count(); if count_trailing > 0 { data.truncate(data.len() - count_trailing); diff --git a/src/traits.rs b/src/traits.rs index 0edb032b8..16d4ed9cb 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -61,7 +61,7 @@ pub trait ParserTrait { fn new(code: Vec, path: &Path, pr: Option>) -> Self; fn get_language(&self) -> LANG; - fn get_root(&self) -> Node; + fn get_root(&self) -> Node<'_>; fn get_code(&self) -> &[u8]; fn get_filters(&self, filters: &[String]) -> Filter; } From 994589f35472d043a8c10cda290591ca582e9cf8 Mon Sep 17 00:00:00 2001 From: Marlon Costa Date: Mon, 19 Jan 2026 20:54:53 -0300 Subject: [PATCH 3/4] chore: Remove accidental .gitignore change --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4732d5498..97dc21d31 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ target enums/target *~ Cargo.lock -.claude/ From 2a387f11c93aa6c5b0625aaec50f5f4e368c61b6 Mon Sep 17 00:00:00 2001 From: Marlon Costa Date: Mon, 19 Jan 2026 20:55:29 -0300 Subject: [PATCH 4/4] chore: Remove accidental .claude directory --- .../affected-repos.txt | 2 - .../edited-files.log | 87 ------------------- 2 files changed, 89 deletions(-) delete mode 100644 .claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt delete mode 100644 .claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log diff --git a/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt b/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt deleted file mode 100644 index 830455972..000000000 --- a/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/affected-repos.txt +++ /dev/null @@ -1,2 +0,0 @@ -root -src diff --git a/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log b/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log deleted file mode 100644 index 26b6f2405..000000000 --- a/.claude/tsc-cache/065ed7c5-46e6-4abe-8b1e-57df8621d7e7/edited-files.log +++ /dev/null @@ -1,87 +0,0 @@ -1768840242:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840302:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840387:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840388:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840418:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840419:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840540:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840541:/tmp/rca-fork-1768837625/Cargo.toml:root -1768840850:/tmp/rca-fork-1768837625/.gitignore:root -1768842340:/tmp/rca-fork-1768837625/src/node.rs:src -1768842438:/tmp/rca-fork-1768837625/src/traits.rs:src -1768842448:/tmp/rca-fork-1768837625/src/node.rs:src -1768842459:/tmp/rca-fork-1768837625/src/node.rs:src -1768842473:/tmp/rca-fork-1768837625/src/node.rs:src -1768843128:/tmp/rca-fork-1768837625/src/asttools.rs:src -1768843150:/tmp/rca-fork-1768837625/src/lib.rs:src -1768843290:/tmp/rca-fork-1768837625/src/metrics/npa.rs:src -1768843308:/tmp/rca-fork-1768837625/src/metrics/npm.rs:src -1768843431:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768843438:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768843443:/tmp/rca-fork-1768837625/src/metrics/cognitive.rs:src -1768843959:/tmp/rca-fork-1768837625/src/asttools.rs:src -1768843960:/tmp/rca-fork-1768837625/src/getter.rs:src -1768843961:/tmp/rca-fork-1768837625/src/getter.rs:src -1768843962:/tmp/rca-fork-1768837625/src/alterator.rs:src -1768843997:/tmp/rca-fork-1768837625/src/node.rs:src -1768844004:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768844041:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768844044:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768844073:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768844093:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768844094:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768844149:/tmp/rca-fork-1768837625/src/metrics/cognitive.rs:src -1768844151:/tmp/rca-fork-1768837625/src/metrics/loc.rs:src -1768844152:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src -1768844154:/tmp/rca-fork-1768837625/src/checker.rs:src -1768844156:/tmp/rca-fork-1768837625/src/find.rs:src -1768844379:/tmp/rca-fork-1768837625/src/checker.rs:src -1768844381:/tmp/rca-fork-1768837625/src/checker.rs:src -1768844383:/tmp/rca-fork-1768837625/src/concurrent_files.rs:src -1768844402:/tmp/rca-fork-1768837625/src/concurrent_files.rs:src -1768845153:/tmp/rca-fork-1768837625/Cargo.toml:root -1768858484:/tmp/rca-fork-1768837625/Cargo.toml:root -1768858580:/tmp/rca-fork-1768837625/src/node.rs:src -1768859149:/tmp/rca-fork-1768837625/src/macros.rs:src -1768859200:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src -1768859210:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src -1768859465:/tmp/rca-fork-1768837625/Cargo.toml:root -1768859497:/tmp/rca-fork-1768837625/src/langs.rs:src -1768859514:/tmp/rca-fork-1768837625/src/macros.rs:src -1768861425:/tmp/rca-fork-1768837625/src/lib.rs:src -1768861527:/tmp/rca-fork-1768837625/src/node.rs:src -1768862461:/tmp/rca-fork-1768837625/src/node.rs:src -1768862667:/tmp/rca-fork-1768837625/src/node.rs:src -1768863000:/tmp/rca-fork-1768837625/src/alterator.rs:src -1768863006:/tmp/rca-fork-1768837625/src/checker.rs:src -1768863013:/tmp/rca-fork-1768837625/src/find.rs:src -1768863031:/tmp/rca-fork-1768837625/src/getter.rs:src -1768863044:/tmp/rca-fork-1768837625/src/getter.rs:src -1768863057:/tmp/rca-fork-1768837625/src/getter.rs:src -1768863086:/tmp/rca-fork-1768837625/src/getter.rs:src -1768863233:/tmp/rca-fork-1768837625/Cargo.toml:root -1768863309:/tmp/rca-fork-1768837625/src/node.rs:src -1768864437:/tmp/rca-fork-1768837625/src/node.rs:src -1768864441:/tmp/rca-fork-1768837625/src/node.rs:src -1768864444:/tmp/rca-fork-1768837625/src/traits.rs:src -1768864446:/tmp/rca-fork-1768837625/src/parser.rs:src -1768864987:/tmp/rca-fork-1768837625/src/tools.rs:src -1768864995:/tmp/rca-fork-1768837625/src/node.rs:src -1768864996:/tmp/rca-fork-1768837625/src/node.rs:src -1768865009:/tmp/rca-fork-1768837625/src/node.rs:src -1768865526:/tmp/rca-fork-1768837625/src/tools.rs:src -1768865527:/tmp/rca-fork-1768837625/src/node.rs:src -1768865529:/tmp/rca-fork-1768837625/src/node.rs:src -1768865531:/tmp/rca-fork-1768837625/src/node.rs:src -1768865532:/tmp/rca-fork-1768837625/src/traits.rs:src -1768865534:/tmp/rca-fork-1768837625/src/parser.rs:src -1768865557:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768865559:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768865560:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768865561:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768865563:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768865564:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768865567:/tmp/rca-fork-1768837625/src/metrics/abc.rs:src -1768865582:/tmp/rca-fork-1768837625/src/metrics/cognitive.rs:src -1768865584:/tmp/rca-fork-1768837625/src/metrics/loc.rs:src -1768865586:/tmp/rca-fork-1768837625/src/metrics/nargs.rs:src