Skip to content

Conversation

@mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Jun 19, 2020

Parameter names were taken directly form the parameter names used in the
cucumber expression. By passing these through the identifier generator
we can ensure that these are valid identifiers.

To reflect this new usage the FunctionNameGenerator was renamed to
IdentifierGenerator. The identifier generator uses a strategy pattern to join
words into method and parameter names.

Parameter names are always generated using the camel case strategy. While
long sentence like method names may be more readable in snake case, it is
expected that people will still want to follow the java conventions for
parameters.

To avoid issues where a parameter name were already in camel case or underscore
case sentences are also split on camel case and underscores (in addition to
whitespace). This also required using all lower case in the UnderscoreJoiner
which has since been renamed to SnakeCaseJoiner.

Fixes: #2028

@mpkorstanje mpkorstanje force-pushed the core-fix-2028-generate-valid-paramter-names branch from 1007030 to 2561050 Compare June 20, 2020 21:18
@mpkorstanje mpkorstanje marked this pull request as ready for review June 20, 2020 21:18
Parameter names were taken directly form the parameter names used in the
cucumber expression. By passing these through the identifier generator
we can ensure that these are valid identifiers.

To reflect this new usage the `FunctionNameGenerator` was renamed to
`IdentifierGenerator`. The identifier generator uses a strategy pattern to join
words into method and parameter names.

Parameter names are always generated using the camel case strategy. While
long sentence like method names may be more readable in snake case, it is
expected that people will still want to follow the java conventions for
parameters.

To avoid issues where a parameter name were already in camel case or underscore
case sentences are also split on camel case and underscores (in addition to
whitespace). This also required using all lower case in the `UnderscoreJoiner`
which has since been renamed to `SnakeCaseJoiner`.

Fixes: #2028
@mpkorstanje mpkorstanje force-pushed the core-fix-2028-generate-valid-paramter-names branch from 2561050 to e4a9a7c Compare June 21, 2020 22:55
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 86.032% when pulling e4a9a7c on core-fix-2028-generate-valid-paramter-names into 1fdf68f on master.

@mpkorstanje mpkorstanje merged commit 3efc606 into master Jun 21, 2020
@mpkorstanje mpkorstanje deleted the core-fix-2028-generate-valid-paramter-names branch June 21, 2020 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect variable names in generated cucumber expressions

3 participants