-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
WIP refactor: code inspection - fix redundant local variable #2377
WIP refactor: code inspection - fix redundant local variable #2377
Conversation
@@ -85,8 +85,7 @@ public void accept(CtReference t) { | |||
@Override | |||
public ScanningMode enter(CtElement element) { | |||
if (ignoredParent != null && element instanceof CtElement) { | |||
CtElement ele = (CtElement) element; | |||
if (ele.hasParent(ignoredParent)) { | |||
if (((CtElement) element).hasParent(ignoredParent)) { |
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.
I really don't agree with this change: generally I'm the one extracting those casts in a local variable. I find it really more readable, and it's really useful when debugging.
Now here I even don't understand why a cast is needed: element is already a CtElement, so we just need to remove the cast, don't we?
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.
I really don't agree with this change: generally I'm the one extracting those casts in a local variable. I find it really more readable, and it's really useful when debugging.
Restored.
Now here I even don't understand why a cast is needed: element is already a CtElement, so we just need to remove the cast, don't we?
We do :-)
BTW. There are many redundant casts. I will take a look and try to fix them in separate PR.
Set<ModifierKind> backup = EnumSet.noneOf(ModifierKind.class); | ||
backup.addAll(workCopy.getModifiers()); | ||
workCopy.removeModifier(ModifierKind.PUBLIC); | ||
backup.addAll(c.getModifiers()); |
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.
Ok with the remove of workCopy but then could you rename the argument of the method: c
is really not something explicit... workType
maybe or whatever.
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.
@surli
Renamed.
if (ignoredParent != null && element instanceof CtElement) { | ||
CtElement ele = (CtElement) element; | ||
if (ele.hasParent(ignoredParent)) { | ||
CtElement ele = element; |
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.
I don't understand the purpose of local variable ele here: IMHO you can just remove this variable and the first if.
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.
WIP |
WIP
DO NOT MERGE