-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat(lint): Add double_parens #24
Merged
0xLucqs
merged 8 commits into
software-mansion:main
from
coxmars:feat/double-parens-lint
Aug 19, 2024
Merged
feat(lint): Add double_parens #24
0xLucqs
merged 8 commits into
software-mansion:main
from
coxmars:feat/double-parens-lint
Aug 19, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can you also add a few more test cases (this is from the clippy codebase) fn dummy_fn<T>(_: T) {}
struct DummyStruct;
impl DummyStruct {
fn dummy_method<T>(self, _: T) {}
}
fn simple_double_parens() -> i32 {
((0))
//~^ ERROR: consider removing unnecessary double parentheses
//~| NOTE: `-D clippy::double-parens` implied by `-D warnings`
}
fn fn_double_parens() {
dummy_fn((0));
//~^ ERROR: consider removing unnecessary double parentheses
}
fn method_double_parens(x: DummyStruct) {
x.dummy_method((0));
//~^ ERROR: consider removing unnecessary double parentheses
}
fn tuple_double_parens() -> (i32, i32) {
((1, 2))
//~^ ERROR: consider removing unnecessary double parentheses
}
fn unit_double_parens() {
(())
//~^ ERROR: consider removing unnecessary double parentheses
}
fn fn_tuple_ok() {
dummy_fn((1, 2));
}
fn method_tuple_ok(x: DummyStruct) {
x.dummy_method((1, 2));
}
fn fn_unit_ok() {
dummy_fn(());
}
fn method_unit_ok(x: DummyStruct) {
x.dummy_method(());
}
// Issue #3206
fn inside_macro() {
assert_eq!((1, 2), (1, 2), "Error");
assert_eq!(((1, 2)), (1, 2), "Error");
//~^ ERROR: consider removing unnecessary double parentheses
}
fn main() {} |
Hi @0xLucqs I already add more test for this lint, 10 in total and I tested and it is working. Let me know if you need something else, thanks 🫡 |
0xLucqs
reviewed
Aug 15, 2024
0xLucqs
suggested changes
Aug 16, 2024
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.
Rebase and apply the suggestion and it's good to go
coxmars
force-pushed
the
feat/double-parens-lint
branch
from
August 17, 2024 18:36
846e943
to
345fc3d
Compare
0xLucqs
previously approved these changes
Aug 19, 2024
coxmars
force-pushed
the
feat/double-parens-lint
branch
from
August 19, 2024 19:24
2e9fef0
to
775a37d
Compare
0xLucqs
approved these changes
Aug 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary 📌
This PR introduces a new lint
double_parens
that detects and removes unnecessary double parentheses, improving code readability.Changes Made ⚡️
Implementation of
double_parens
Lintplugin.rs
to detect and fix double parentheses.fix.rs
, ensuring that unnecessary parentheses are removed while preserving the original code structure.tests.rs
.Test Coverage 🥷🏼
test_files/double_parens
to validate thedouble_parens
lint:Test Results ✅