Refactor the loop in check_authorization_status - #149
Open
rozgonik wants to merge 1 commit into
Open
Conversation
Codecov Report
@@ Coverage Diff @@
## master #149 +/- ##
=========================================
+ Coverage 86.44% 86.5% +0.06%
=========================================
Files 14 14
Lines 944 941 -3
=========================================
- Hits 816 814 -2
+ Misses 128 127 -1
|
rozgonik
force-pushed
the
master
branch
2 times, most recently
from
March 15, 2020 17:31
a35a833 to
2d6660d
Compare
Owner
|
@mmaney I'm happy with this PR if you are. |
Collaborator
|
Another old bug/PR that will be part of the get_certificate refactoring work. |
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.
What have you changed?
Changed the while loop with an implicit counter to an explicit for cycle.
Also the "Checks done" and the "Max checks allowed" counter in the StopIteration exception makes no sense, because the two values will be the same (and equal to ACME_AUTH_STATUS_MAX_CHECKS) every time the exception kicks in.
I do not want to fiddle with the exception message, so made the counters reference the same value.
Why did you change it?
@mmaney suggested the refactoring of this method's cycle at #148 in his comment.
Further refactoring can be done in the following way:
However it breaks the convention of ending the method with a logger call and a return statement.
To be consistent I opted to implement a variant with less changes.
(When submitting the original PR I had difficulties finding time for doing a proper refactor, that's why #148 was a quick-n-dirty fix.)
Update:
Sorry for the noise about the force-pushes.
(FYI:
black==18.9b0and the latestblack==19.10b0has different rulesets about trailing commas.)