New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UniformEnumValueNameCheck #445

Closed
pbaranchikov opened this Issue Mar 24, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@pbaranchikov
Contributor

pbaranchikov commented Mar 24, 2016

This check should accept multiple regular expressions for enum values and validate names to conform certain conventions but only one convention in one enum.

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Mar 24, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Mar 24, 2016

Member

Thanks a lot.

UniformEnumValueCheck

https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.9

"EnumConstant" ! We follow jdk names as much as possible.

public void visitToken(DetailAST ast)

logic should be simple but looks very complicated. Need to be re-factored to be a might be less efficient but friendly for human.

please make it like:

enumValueTokens = getTokensbyType(TokenType.ENUM_CONSTANT_DEF);
final String enumName =  ....
BitSet matches = matchPatterns(enumName);
if (matches.isEmpty || matches.cardinality > 1) {
....

https://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html#cardinality%28%29

such update will resolve extra "return" and extra "continue".

I need separate PR for gh-pages branch, https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/List-of-files-that-need-to-be-updated-for-new-field-or-new-Check-implementation

Member

romani commented Mar 24, 2016

Thanks a lot.

UniformEnumValueCheck

https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.9

"EnumConstant" ! We follow jdk names as much as possible.

public void visitToken(DetailAST ast)

logic should be simple but looks very complicated. Need to be re-factored to be a might be less efficient but friendly for human.

please make it like:

enumValueTokens = getTokensbyType(TokenType.ENUM_CONSTANT_DEF);
final String enumName =  ....
BitSet matches = matchPatterns(enumName);
if (matches.isEmpty || matches.cardinality > 1) {
....

https://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html#cardinality%28%29

such update will resolve extra "return" and extra "continue".

I need separate PR for gh-pages branch, https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/List-of-files-that-need-to-be-updated-for-new-field-or-new-Check-implementation

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 13, 2016

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 13, 2016

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 13, 2016

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 14, 2016

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 29, 2016

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 29, 2016

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue May 19, 2016

pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue May 20, 2016

@romani romani added this to the 1.21 milestone Jun 5, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 5, 2016

Member

fix is merged.

Member

romani commented Jun 5, 2016

fix is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment