Remove redundant progress monitor done() calls#2340
Draft
vogella wants to merge 1 commit into
Draft
Conversation
Test Results 126 files ±0 126 suites ±0 36m 59s ⏱️ + 1m 54s For more details on these failures, see this check. Results for commit 13cf067. ± Comparison against base commit 4f1f320. ♻️ This comment has been updated with latest results. |
SubMonitor.done() is effectively a no-op in well-formed code: the parent SubMonitor.convert call already manages parent ticks, so explicit done() on a SubMonitor is unnecessary. Where the only purpose of a try/finally block was to call done(), the block has been removed and the body de-indented. Likewise, calling done() on the raw IProgressMonitor parameter is an antipattern: only the code that created the monitor is supposed to call done() on it. This affects Job.run overrides (where the Jobs framework already invokes done()) and methods that receive a monitor from a caller (where the caller owns its lifecycle), so the calls in TargetPlatformPreferencePage.LoadDefaultTargetJob and AbstractBundleContainer.resolve have been removed too. In TargetPlatformPreferencePage.LoadDefaultTargetJob the SubMonitor was created but never used to report progress, so the convert call and its now-unused import are removed as well. Reference: https://www.eclipse.org/articles/Article-Progress-Monitors/article.html
a1ae1ca to
13cf067
Compare
This file contains hidden or 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
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.
SubMonitor.done()is effectively a no-op in well-formed code because the parentSubMonitor.convertcall already manages parent ticks. Where the only purpose of atry/finallyblock was to calldone(), the block has been removed and the body de-indented.Calling
done()on the rawIProgressMonitorparameter is also an antipattern: only the code that created the monitor is supposed to calldone()on it. That coversJob.runoverrides (the Jobs framework already does it) and methods that receive a monitor from a caller (the caller owns its lifecycle). InTargetPlatformPreferencePage.LoadDefaultTargetJobtheSubMonitorwas created but never used to report progress, so theconvertcall and its now-unused import are removed too.Reference: https://www.eclipse.org/articles/Article-Progress-Monitors/article.html
Planned for 4.41