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

[java] CommentDefaultAccessModifierRule FP with nested enums #1154

Merged
merged 2 commits into from Jun 13, 2018

Conversation

Projects
None yet
2 participants
@jsotuyod
Member

jsotuyod commented May 30, 2018

  • Enum constructors should not be reported, even if nested
  • Nested annotation members should not be reported
[java] Fix FP with CommentDefaultAccessModifierRule
 - Enum constructors should not be reported, even if nested
 - Nested annotation members should not be reported

@adangel adangel self-assigned this Jun 11, 2018

@adangel adangel changed the title from [java] Fix FP with CommentDefaultAccessModifierRule to [java] CommentDefaultAccessModifierRule FP with nested enums Jun 11, 2018

@adangel

@jsotuyod looks good!
Let me know, if I should change the code to use getTypeKind() when I merge it.

final boolean isConcreteClass = parentClassOrInterface instanceof ASTClassOrInterfaceDeclaration
&& !((ASTClassOrInterfaceDeclaration) parentClassOrInterface).isInterface();
final boolean isEnumConstructor = parentClassOrInterface instanceof ASTEnumDeclaration
&& decl instanceof ASTConstructorDeclaration;

This comment has been minimized.

@adangel

adangel Jun 11, 2018

Member

I think, you can use here net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration.getTypeKind() to figure out, whether it's an enum, interface or class.

boolean isConcreteClass = parentClassOrInterface.getTypeKind() == ASTAnyTypeDeclaration.TypeKind.CLASS;
boolean isEnumConstructor = parentClassOrInterface.getTypeKind() == ASTAnyTypeDeclaration.TypeKind.ENUM && decl instanceof ASTConstructor;

Hm... I hoped, it would pan out nicer... but at least, it leverages the ASTAnyTypeDeclaration API 😄

This comment has been minimized.

@jsotuyod

jsotuyod Jun 11, 2018

Member

Feel free to do so!

@adangel adangel merged commit 78c437b into pmd:master Jun 13, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

adangel added a commit that referenced this pull request Jun 13, 2018

@jsotuyod jsotuyod deleted the Monits:fp-commentdefault branch Jun 13, 2018

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