Skip to content
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

adminchannel: fix, simplify, and comment hostmask utility function #2222

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

dgw
Copy link
Member

@dgw dgw commented Dec 8, 2021

Description

The "Big boy" version of #2221.

This is perhaps the most roundabout way to resolve a single LGTM alert in Sopel's history, but it improves a lot of stuff about the adminchannel plugin's configureHostMask helper function:

  • Fix a broken regex (unmatchable caret, the thing LGTM complained about)
  • Reduce the number of distinct cases
  • Add comments explaining what each case is supposed to do
  • Use exceptions to alert the caller about invalid input instead of a weak sentinel value of '' (empty string)
  • Add test cases to make sure that everything behaves as expected

Notably, adding tests also picked out a couple of edge cases that weren't handled, which I then also fixed.

The "Big boy" version of #2221.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches
    • Well yes, that's what the new file under test/ is for.

dgw added 3 commits December 7, 2021 17:23
I came for the LGTM alert about an unmatchable caret, and stayed for the
completely undocumented behavior.

Since the function works fine with just about any input consisting only
of wildcards, I eliminated matching `*!*@*` as a special case.

Fixed a typo (from 2014) in the regex for `nick!user` format (source of
the LGTM alert that brought me here).

Made the full-format validation stricter, disallowing the NUH field
delimiters inside each field.

And finally, added comments to make the string of regex checks less
opaque to the first-time reader.
If it had been something sensible like `None` I might have let it go,
but using the empty string '' as a sentinel value feels squicky.
Created test suite and caught (then fixed) some edge cases.
@dgw dgw added Bugfix Generally, PRs that reference (and fix) one or more issue(s) Housekeeping Code cleanup, removal of deprecated stuff, etc. labels Dec 8, 2021
@dgw dgw added this to the 8.0.0 milestone Dec 8, 2021
@dgw dgw requested a review from a team December 8, 2021 07:45
Copy link
Contributor

@Exirel Exirel left a 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 everything, but there are tests, and they look way easier to understand, so I'm all for it. 👍

@dgw dgw merged commit 8beb56a into master Dec 9, 2021
@dgw dgw deleted the adminchannel-hostmask-fix branch December 9, 2021 18:25
@dgw
Copy link
Member Author

dgw commented Dec 9, 2021

Merged along with #2221 so we don't have a fixed bug in stable that's still unfixed on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix Generally, PRs that reference (and fix) one or more issue(s) Housekeeping Code cleanup, removal of deprecated stuff, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants