Correctly convert SCREAMING_SNAKE_CASE
#1884
Closed
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.
Suggestion cannot be applied right now. Please check back later.
The problem of normalizing casings is a very interesting one.
I've decided to reimplement the function, partly to make it more readable as well.
It's trivial to implement a function that converts consistent input to consistent output, the issue lies with converting nonsensical input (weird casings and case exceptions) to sensible output, especially while acting purely locally.
These are the test cases that would be different for the original implementation:
SCREAMINGSCREAMINGScreamingStill_Not___ScreamingStillNotScreamingStill_Not___ScreamingStill_Not___screamingStillNot_screamingStill_Not___screamingstill_not___screamingStillNotScreamingStillNot___screaming_D_D__D__d_D_d_MyCool2d_stringMyCool2d_stringMyCool2dStringMyCool2_d_StringMyCool2_dStringMyCool2D_StringMyC_de_coolMyC_de_coolMyC_deCoolm_d_d_dMDDDM_dD_dm_d_d_d(LowerCamelCase)mDDDmD_dD__m_d_d_dMDDD__mD_dDThe questions of design are:
MDDDtest case. I recognize that the previous handling of this case was superior, however, this case is highly synthetic (in general the test cases are not solely intended to represent real world scenarios, but to capture design decisions made).In conclusion I believe the new implementation is generally more stable, consistent and sensible in realistic edge cases.