Add UniformEnumValueNameCheck #445

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

Projects

None yet

2 participants

@pbaranchikov
Contributor

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 pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Mar 24, 2016
@pbaranchikov pbaranchikov Issue #445 Implemented UniformEnumValueCheck 711d688
@romani
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 pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 13, 2016
@pbaranchikov pbaranchikov Issue #445 Implemented UniformEnumValueCheck 59d051c
@pbaranchikov pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 13, 2016
@pbaranchikov pbaranchikov Issue #445 Implemented UniformEnumValueCheck 255007a
@pbaranchikov pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 13, 2016
@pbaranchikov pbaranchikov Issue #445 Added UniformEnumValueCheck to default checkstyle confitur…
…ation
c1ccc44
@pbaranchikov pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 14, 2016
@pbaranchikov pbaranchikov Issue #445 Added UniformEnumValueCheck to default checkstyle confitur…
…ation
736f901
@pbaranchikov pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 29, 2016
@pbaranchikov pbaranchikov Issue #445 Implemented UniformEnumValueCheck 9eacb87
@pbaranchikov pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue Apr 29, 2016
@pbaranchikov pbaranchikov Issue #445 Implemented UniformEnumValueCheck 324a909
@pbaranchikov pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue May 19, 2016
@pbaranchikov pbaranchikov Issue #445 Implemented UniformEnumValueCheck ec4a5bd
@pbaranchikov pbaranchikov added a commit to pbaranchikov/sevntu.checkstyle that referenced this issue May 20, 2016
@pbaranchikov pbaranchikov Issue #445 Implemented UniformEnumValueCheck 024dc29
@romani romani added this to the 1.21 milestone Jun 5, 2016
@romani
Member
romani commented Jun 5, 2016

fix is merged.

@romani romani closed this Jun 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment