-
Notifications
You must be signed in to change notification settings - Fork 82
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
refactor: simplify identifier length validation #960
Conversation
Firstly, remove asserts from the validate_identifier_length and validate_prefix_length functions. Instead, let the regular checks handle cases where min and max constraints don’t allow for a valid prefix to exist. Secondly, ensure minimum length constraints is at least one. This makes sure that the validation functions will check for empty identifiers and prefixes. This makes empty identifier check in validate_channel_identifier as well as Error::Empty variant unnecessary so get rid of those too. Lastly, collapse all checks in validate_prefix_length into a single call to validate_identifier_length with correctly adjusted min and max constraints. Issue: cosmos#959
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #960 +/- ##
==========================================
- Coverage 66.38% 66.33% -0.06%
==========================================
Files 161 161
Lines 15767 15743 -24
==========================================
- Hits 10467 10443 -24
Misses 5300 5300
☔ View full report in Codecov by Sentry. |
@rnbguy, I guess it’s ready for review if you like it then. |
Signed-off-by: Michal Nazarewicz <[email protected]>
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.
Thanks, @mina86 ! Requested a few changes.
.changelog/unreleased/breaking-changes/960-simplify-length-validation.md
Outdated
Show resolved
Hide resolved
…ength-validation.md Signed-off-by: Michal Nazarewicz <[email protected]>
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.
* refactor: simplify identifier length validation Firstly, remove asserts from the validate_identifier_length and validate_prefix_length functions. Instead, let the regular checks handle cases where min and max constraints don’t allow for a valid prefix to exist. Secondly, ensure minimum length constraints is at least one. This makes sure that the validation functions will check for empty identifiers and prefixes. This makes empty identifier check in validate_channel_identifier as well as Error::Empty variant unnecessary so get rid of those too. Lastly, collapse all checks in validate_prefix_length into a single call to validate_identifier_length with correctly adjusted min and max constraints. Issue: #959 * log * Update 960-simplify-length-validation.md Signed-off-by: Michal Nazarewicz <[email protected]> * tests * Update and rename 960-simplify-length-validation.md to 961-simplify-length-validation.md Signed-off-by: Michal Nazarewicz <[email protected]> * update changelog entry * revert error variant deletion * refactor id validation tests * use numeral consistently --------- Signed-off-by: Michal Nazarewicz <[email protected]> Co-authored-by: Ranadeep Biswas <[email protected]>
Firstly, remove asserts from the validate_identifier_length and
validate_prefix_length functions. Instead, let the regular checks
handle cases where min and max constraints don’t allow for a valid
prefix to exist.
Secondly, ensure minimum length constraints is at least one. This
makes sure that the validation functions will check for empty
identifiers and prefixes. This makes empty identifier check in
validate_channel_identifier as well as IdentifierError::Empty variant
unnecessary so get rid of those too.
Lastly, collapse all checks in validate_prefix_length into a single
call to validate_identifier_length with correctly adjusted min and max
constraints.
Closes: #961
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.