Skip to content

[java] Refactor annotation suppression#1927

Merged
oowekyala merged 7 commits into
pmd:java-grammarfrom
oowekyala:grammar-annotation-suppression
Sep 25, 2019
Merged

[java] Refactor annotation suppression#1927
oowekyala merged 7 commits into
pmd:java-grammarfrom
oowekyala:grammar-annotation-suppression

Conversation

@oowekyala

Copy link
Copy Markdown
Member

This removes the need for the Java CanSuppressWarnings interface, and decouples the AST from rules.
See also this PR comment.

The implementation of the interface was duplicated 4 times, but we can use Annotatable to remove the duplication.

Relevant regression tests are in SuppressWarningsTest, which isn't touched by this PR.

TODO on master:

  • Deprecate CanSuppressWarnings and implemented methods
  • Maybe, deprecate JavaRuleViolation::isSupressed: there's a typo in the method name, and it doesn't need to be public
  • I'm also not sure we need AbstractJavaRule::isSuppressed. It seems like it's only used by one rule deprecated for removal

Notes:

  • Apex also has CanSuppressWarnings and the implementations are also perfect duplicates (7 times).
  • We could avoid hardcoding the suppressed rule names, and instead use eg an annotation on the rule class (eg SuppressionGroup("unused")), which would make the suppression mechanism extensible, and also usable by end-users.

@oowekyala oowekyala added the in:ast About the AST structure or API, the parsing step label Jul 21, 2019
@oowekyala oowekyala added this to the 7.0.0 milestone Jul 21, 2019
oowekyala added a commit that referenced this pull request Sep 24, 2019
* nspmd.lang.java.dfa
* nspmd.lang.java.symboltable
* Some of nspmd.lang.java.metrics

The remaining failures are fixed by #1927
@ghost

ghost commented Sep 24, 2019

Copy link
Copy Markdown
1 Message
📖 No java rules are changed!

Generated by 🚫 Danger

}

/**
* @deprecated Used in only one deprecated rule, which is removed by pending PR #1772

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1772 is now merged… shall this method be removed altogether and deprecated in master?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact that comment is wrong, the PR removing that rule is #2022 (rules are the old [Std|Modified]CyclomaticComplexity). But I deprecated the method in #2031

@jsotuyod

Copy link
Copy Markdown
Member

@oowekyala other than that one doubt this looks mergeable. We should also deprecate CanSuppressWarnings from master on a separate PR.

@oowekyala oowekyala merged commit 16cfc43 into pmd:java-grammar Sep 25, 2019
@oowekyala oowekyala deleted the grammar-annotation-suppression branch September 25, 2019 20:54
@oowekyala oowekyala mentioned this pull request Oct 6, 2019
2 tasks
@adangel adangel mentioned this pull request May 23, 2020
6 tasks
@adangel adangel mentioned this pull request Jan 11, 2023
1 task
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:ast About the AST structure or API, the parsing step

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants