Reduce duplication between code and snippet generation#3127
Conversation
|
Build fail with error : [ERROR] java.class.externalClassExposedInAPI: class io.cucumber.gherkin.GherkinDialect: A class from supplementary archives is used in a public capacity in the API. [io.cucumber:gherkin:jar:36.1.0] @mpkorstanje can you advice in which module should i put GherkinKeywordNormalizer class ? |
|
I'll have to think about that for a minute. It might be that we'd have to move this to the |
|
@mpkorstanje that makes perfect sense. Shifting this to the |
|
I thought about it for a while. And normalization happens in a context. In this case we want identifiers that are safe to use in Java class and package names. That context is lost if this were to be moved to the Gherkin library. |
mpkorstanje
left a comment
There was a problem hiding this comment.
Looks good. I've pushed some small changes while reviewing. Please do:
- Remove
capitalizefrom the public API - Add a few test for both remaining public methods.
| return language.replaceAll("[\\s-]", "_").toLowerCase(); | ||
| } | ||
|
|
||
| public static String capitalize(String str) { |
There was a problem hiding this comment.
This doesn't quite belong. Please make private and duplicate as needed.
|
@mpkorstanje done. Thanks for your review! |
|
Cheers! |
|
Thank you for your valuable feedback and review |
Fixes #3063
🤔 What's changed?
⚡️ What's your motivation?
As seen in #3062 currently boths GenerateI18n classes for cucumber-java[8] and SnippetGenerator turn Gherkin keywords into code. This code is now duplicated 3 times over. Each with a special exception for Emoji.
🏷️ What kind of change is this?
🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)
I agree to respect and uphold the Cucumber Community Code of Conduct