Clean Code for bundles/org.eclipse.core.commands#3258
Conversation
|
|
||
| // Check if they're the same type. | ||
| if (!(object instanceof HandleObject)) { | ||
| if (!(object instanceof final HandleObject handle)) { |
There was a problem hiding this comment.
@jjohnstn this looks a bit strange and it seems final is not added to all instanceof checks (where I assume we likely never modify variables used in instanceof checks anyways)
There was a problem hiding this comment.
The "add final" cleanup was modified to start with a fresh AST and apply previous cleanups. So, if you asked for the pattern instanceof cleanup, the final cleanup will see the new pattern variable that was added and will make it final if conditions are appropriate. In the past, the final cleanup would not have seen the new pattern instanceof expression.
There was a problem hiding this comment.
@jjohnstn so while your explanation seems valid to me, I suspect something is wrong here, because I would not have expected this because we only enabled to make fields as
Add final modifier to private fields
but not for local variables or parameters...
So is my expectation maybe wrong?
There was a problem hiding this comment.
Actually, in this case, the declaration of handle that is used to make the pattern instanceof variable is declared final and casts object to HandleObject. The code is doing the right thing. You have a final HandleObject called handle in both cases.
There was a problem hiding this comment.
I think I begin to understand so because previously
final HandleObject handle= (HandleObject) object;
is defined final this is applied to the instanceof as well.. now it seems obvious, thanks for the pointer!
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
Test Results 2 904 files ±0 2 904 suites ±0 2h 8m 43s ⏱️ - 2m 39s For more details on these failures, see this check. Results for commit cc1be79. ± Comparison against base commit de7ee8c. ♻️ This comment has been updated with latest results. |
d15b102 to
7c6b103
Compare
a308562 to
0cfd0be
Compare
The following cleanups were applied: