[
https://issues.apache.org/jira/browse/OPENNLP-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18121385#comment-18121385
]
ASF GitHub Bot commented on OPENNLP-1935:
-----------------------------------------
krickert opened a new pull request, #1348:
URL: https://github.com/apache/opennlp/pull/1348
Part 10 of the regex removal series, kept as a draft until the remaining
classes are converted. Continues #1282 on an apache branch.
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.replaceFirst` and
`Scanner.useDelimiter`. It runs at `process-classes`, before the tests, and its
message names the `StringUtil` replacements. Tests are not checked, so test
code can keep using regular expressions.
Exceptions: a member with a documented public contract that is a
user-supplied regular expression is marked with `@SuppressForbidden(reason)`.
Only `RegexNameFinder` and `RegexNameFinderFactory` have it. A private pattern
is converted, not annotated, so the report of the check is the to-fix list for
the rest of the series. `CONTRIBUTING.md` has the rule.
Also in this PR: `StringUtil` has one non-empty split loop behind
`splitNonEmpty`, `splitOnUnicodeWhitespace` and the mode-aware
`splitOnWhitespace`, replacing the copies in `EventFields`, `MascIdentifiers`,
`MecabDictionary` and `HunspellDictionary`. The remaining `String.split` calls
in `ConlluStream`, `TokenSampleStream` and `DownloadUtil` use the helpers.
Report on main today: 106 findings in 15 classes. The tokenizer factories
and `TokenizerME`, the parser family, `NameSample`, `FeatureGeneratorUtil`, the
two normalizers, and the rest of `ConlluStream`, `DownloadUtil` and
`TokenSampleStream`. `BasicContextGenerator` is #1280.
[OPENNLP-1935](https://issues.apache.org/jira/browse/OPENNLP-1935)
> RegEx removal part 10: forbiddenapis guard for java.util.regex in production
> code
> ---------------------------------------------------------------------------------
>
> Key: OPENNLP-1935
> URL: https://issues.apache.org/jira/browse/OPENNLP-1935
> Project: OpenNLP
> Issue Type: Improvement
> Components: Build, Packaging and Test
> Reporter: Kristian Rickert
> Assignee: Kristian Rickert
> Priority: Major
> Fix For: 3.0.0
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> Once this is done, let's put safeguards in place to prevent regex during the
> build except for the spots we have exceptions. It's too easy and standard in
> the language to add them.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)