Repository navigation
OPENNLP-1935: Regex removal (10/10): Forbid java.util.regex in production code via forbiddenapis - #1282
OPENNLP-1935: Regex removal (10/10): Forbid java.util.regex in production code via forbiddenapis#1282krickert wants to merge 1 commit into
Conversation
4a3eeb2 to
4e62535
Compare
4e62535 to
25bc925
Compare
rzo1
left a comment
There was a problem hiding this comment.
Little time, so here is a GPT 5.6-sol review instead for now
No additional blocking findings. The guard configuration passes targeted validation. Merge after the implementation PRs and their fixes.
Validation across the combined stack: 1,856 targeted tests, zero failures, one skipped.
25bc925 to
b4d1f4a
Compare
|
Here are some additional comments. I think forbiddenapis would be the bigger gain here than checkstyle. It is already configured in the parent pom, it checks compiled bytecode instead of source text, and it closes every gap listed in item 1. Blocking
Minor
Verified:
|
a0d5415 to
a37187a
Compare
|
Dependency note: #1302 (OPENNLP-1955) supplies the sanctioned replacement for literal |
|
Needs rebase and PR/issue re-runging (working). |
d2acda6 to
b41c024
Compare
|
This isn't a stacked PR and has > 100 commits + 9k additions. It is totally unclear to me what this is about. |
The JIRA was confusing, I made it normal. The title is right - 3 files to prevent regex in the future from sneaking in. I think it's a good idea. This is the last of the regex stack, don't want to cause a false positive on the errors so it was stacked. Once they come in it'll look normal. I'll send an email to explain |
eda3767 to
ae17400
Compare
|
We're getting closer to 10, so I got around to cleaning this up. It'll be red by design. We can do a last merge once all of 'em are rung out |
…napis Add a forbiddenapis check for production classes in every module. Reject java.util.regex and regex-based String and Scanner methods at process-classes, before tests run. Exclude test classes and point error messages to the StringUtil replacements. Add SuppressForbidden for documented APIs that accept user-supplied regular expressions. Require a reason for each exception and apply it to RegexNameFinder and RegexNameFinderFactory. Document the rule, dev/forbidden-regex.txt and allowed exceptions in CONTRIBUTING.md. The build will fail until the remaining production regex uses are removed by the related PRs. Assisted-by: Claude Code 2.1.281 Co-authored-by: Kristian Rickert <kristian@apache.org> Co-authored-by: Claude <noreply@anthropic.com> Reviewed-by: Kristian Rickert <kristian@apache.org> Signed-off-by: Kristian Rickert <kristian@apache.org>
ae17400 to
3699728
Compare
|
@krickert Please rebase onto main. #1302 is in now, so the While at it: And again, please push your branches to |
|
Rebased onto main. With that, the guard on main reports the classes still to do: the tokenizer factories and On the fork: understood. This branch is on apache/opennlp from here on. Continued in #1348. |
Part 10 of the regex removal series. This is the last of them and will remain in draft (this comment will be edited before we say it's ready as well).
This ticket provides a forbiddenapis execution checks the production classes of every module against
dev/forbidden-regex.txt:java.util.regex,String.split,String.matches,String.replaceAll,String.replaceFirstandScanner.useDelimiter. It runs atprocess-classes, before the tests, and its message names the StringUtil replacements. Tests are not checked, so test code can keep using regex.Exceptions: a member with a documented public contract that is a user-supplied regular expression is marked with
@SuppressForbidden(reason). OnlyRegexNameFinderandRegexNameFinderFactoryhave it. A private pattern is converted, not annotated, so the check's report is the to-fix list for the rest of the series.CONTRIBUTING.mdhas the rule.OPENNLP-1935