-
Notifications
You must be signed in to change notification settings - Fork 59
fix: Address clippy collapsible_if warnings with let-chains #1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
There was a problem hiding this 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
|
Updated with additional fixes for all 18 clippy warnings: Changes in this PR:
Files modified:
Note: The |
|
Remove |
Luni-4
left a comment
There was a problem hiding this 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!
Summary
Address clippy
collapsible_ifwarnings 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:Files Modified
rust-code-analysis-cli/src/main.rs: preproc_lock handlingsrc/alterator.rs: CppCode PreprocDef newline handlingsrc/checker.rs: RustCode is_useful_comment checksrc/find.rs: Find callback file printingsrc/getter.rs: PythonCode string handling, CppCode function name extractionTest plan
cargo checkpasses