Simplify and optimize IllegalSequenceRule #89
Merged
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.
Rewrote IllegalSequenceRule to be much shorter and more efficient.
Other than the refactor, the functionality has also changed in one respect: if the illegal sequence length is set to e.g. 5 numerals, and the input password contains the sequence 1234567, then the new implementation will return the full illegal sequence 1234567 in the error result whereas the old implementation would return 3 illegal sequences 12345, 23456, 34567 (and not the full illegal sequence).
While it would be easy to support the previous functionality also after the refactor, I think the new behavior is more intuitive and informative, and the previously returned multiple subsequences, while technically correct, are not as useful (of course for every invalid sequence all subsequences of the configured length are also invalid... but the main sequence is the more interesting one to know about, which the old implementation misses.)
Also updated the tests for the new behavior, and added a few more interesting cases to the tests.