-
-
Notifications
You must be signed in to change notification settings - Fork 721
refactor(minifier): remove clippy::unused_self allow directive by converting methods to associated functions #13029
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
refactor(minifier): remove clippy::unused_self allow directive by converting methods to associated functions #13029
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
…emplate_literal to associated functions Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
…ctions Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
… functions Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
…ions Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
#![allow(clippy::unused_self)] in @oxc-project/oxc/files/crates/oxc_minifier/src/peephole/mod.rs
CodSpeed Instrumentation Performance ReportMerging #13029 will not alter performanceComparing Summary
|
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 removes the #![allow(clippy::unused_self)] directive from the peephole optimization module by converting methods that don't use their &self parameter to associated functions. This improves code clarity by making it explicit when methods are pure utility functions versus methods that operate on instance state.
Key changes:
- Removed blanket clippy allow directive for unused_self warnings
- Converted 14+ instance methods to associated functions across multiple files
- Updated all call sites to use
Self::method()orPeepholeOptimizations::method()syntax
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs |
Converted multiple property/expression manipulation methods to associated functions |
crates/oxc_minifier/src/peephole/replace_known_methods.rs |
Converted utility methods for folding mathematical operations and method calls |
crates/oxc_minifier/src/peephole/remove_unused_expression.rs |
Converted expression removal and folding methods to associated functions |
crates/oxc_minifier/src/peephole/remove_dead_code.rs |
Converted dead code elimination methods to associated functions |
crates/oxc_minifier/src/peephole/normalize.rs |
Converted console compression method to associated function |
crates/oxc_minifier/src/peephole/mod.rs |
Removed clippy directive and updated all method calls throughout the main module |
crates/oxc_minifier/src/peephole/minimize_statements.rs |
Converted statement minimization methods to associated functions |
crates/oxc_minifier/src/peephole/minimize_not_expression.rs |
Converted NOT expression minimization methods to associated functions |
crates/oxc_minifier/src/peephole/minimize_logical_expression.rs |
Converted logical expression minimization method to associated function |
crates/oxc_minifier/src/peephole/minimize_if_statement.rs |
Converted IF statement minimization methods to associated functions |
crates/oxc_minifier/src/peephole/minimize_for_statement.rs |
Converted FOR loop minimization method to associated function |
crates/oxc_minifier/src/peephole/minimize_expression_in_boolean_context.rs |
Converted boolean context optimization methods to associated functions |
crates/oxc_minifier/src/peephole/minimize_conditions.rs |
Converted conditional expression methods to associated functions |
crates/oxc_minifier/src/peephole/minimize_conditional_expression.rs |
Converted conditional expression minimization methods to associated functions |
crates/oxc_minifier/src/peephole/inline.rs |
Converted symbol value and identifier inlining methods to associated functions |
crates/oxc_minifier/src/peephole/fold_constants.rs |
Converted object expression and template literal methods to associated functions |
This PR removes the
#![allow(clippy::unused_self)]directive fromcrates/oxc_minifier/src/peephole/mod.rsby systematically converting methods that don't actually use their&selfparameter to associated functions.Background
The minifier peephole optimization module had 31 methods with unused
&selfparameters that were being suppressed by a blanket allow directive. Instead of suppressing these warnings, this PR fixes the underlying issue by converting these utility methods to associated functions where appropriate.Changes Made
Removed
#![allow(clippy::unused_self)]directive from peephole moduleConverted 14+ methods from instance methods to associated functions across multiple files:
fold_object_expandinline_template_literalinfold_constants.rsinit_symbol_valueandinline_identifier_referenceininline.rsminimize_logical_expressioninminimize_logical_expression.rstry_fold_pow,try_fold_concat_chain,try_fold_concat, andtry_fold_number_constantsinreplace_known_methods.rscompress_consoleinnormalize.rsremove_dead_code_call_expressioninremove_dead_code.rswrap_to_avoid_ambiguous_elseinminimize_if_statement.rssubstitute_alternate_syntax.rsUpdated all call sites to use
Self::method()orPeepholeOptimizations::method()syntax instead ofself.method()Pattern
The refactoring follows a consistent pattern:
Validation
This change improves code clarity by making it explicit when methods are pure utility functions versus methods that operate on instance state.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.