Skip to content

Conversation

@marlon-costa-dc
Copy link
Contributor

Summary

Address clippy collapsible_if warnings by converting nested if-let statements to let-chains (Rust 2024 edition feature).

This PR is separated from the dependency updates (#1207) as requested, and should land first.

Changes

Convert nested if let Some(x) = ... { if condition { ... } } patterns to cleaner let-chains:

// Before
if let Some(x) = foo() {
    if x.is_valid() {
        do_something();
    }
}

// After
if let Some(x) = foo()
    && x.is_valid()
{
    do_something();
}

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

Test plan

  • cargo check passes
  • No functional changes, only code style improvements

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
Copilot AI review requested due to automatic review settings January 19, 2026 22:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the codebase by converting nested if-let statements to let-chains, a Rust 2024 edition feature that improves code readability and addresses clippy collapsible_if warnings.

Changes:

  • Converted five instances of nested if-let patterns to let-chains across the codebase
  • Applied consistent formatting for the new let-chain syntax
  • No functional logic changes intended

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rust-code-analysis-cli/src/main.rs Simplified preproc_lock handling using let-chains
src/alterator.rs Cleaned up CppCode PreprocDef newline removal logic
src/checker.rs Simplified RustCode is_useful_comment check
src/find.rs Streamlined Find callback file printing condition
src/getter.rs Updated PythonCode string handling and CppCode function name extraction (contains syntax error)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ions

- 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
@marlon-costa-dc
Copy link
Contributor Author

Updated with additional fixes for all 18 clippy warnings:

Changes in this PR:

  1. Collapsible if statements - Converted nested if blocks to Rust 2024 let-chains syntax
  2. Lifetime annotations - Added explicit <'_> lifetime annotations to get_root() method signatures
  3. Unnecessary parentheses - Removed in closure body in src/tools.rs
  4. Formatting - Fixed let-chain formatting in src/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

Note: The .claude/ directory and .gitignore change were accidentally included in the commit. These can be removed if needed.

@Luni-4
Copy link
Collaborator

Luni-4 commented Jan 19, 2026

@marlon-costa-dc

Remove .claude and .gitignore changes

Copy link
Collaborator

@Luni-4 Luni-4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for me! Thank you!

@Luni-4 Luni-4 merged commit 383c639 into mozilla:master Jan 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants