Skip to content

[java] Implement constant values#2777

Merged
adangel merged 6 commits into
pmd:java-grammarfrom
oowekyala:java-const-values
Sep 17, 2020
Merged

[java] Implement constant values#2777
adangel merged 6 commits into
pmd:java-grammarfrom
oowekyala:java-const-values

Conversation

@oowekyala

Copy link
Copy Markdown
Member

Describe the PR

Finish implementing ASTExpression#getConstValue, by also considering things like references to constant fields, and eg constant string concatenations, additions, etc.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by travis)
  • Added (in-code) documentation (if needed)

@oowekyala oowekyala added this to the 7.0.0 milestone Sep 12, 2020
@ghost

ghost commented Sep 12, 2020

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

Generated by 🚫 Danger

if (constVal instanceof String) {
String stringVal = (String) constVal;
if ("PMD".equals(stringVal)
|| ("PMD." + rule.getName()).equals(stringVal) // NOPMD uselessparentheses false positive

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.

("PMD." + rule.getName()).equals(stringVal) // NOPMD uselessparentheses false positive

Seems to be #2739

@adangel adangel linked an issue Sep 17, 2020 that may be closed by this pull request
@adangel adangel self-assigned this Sep 17, 2020
@adangel adangel merged commit 4820f0c into pmd:java-grammar Sep 17, 2020
@oowekyala oowekyala deleted the java-const-values branch September 17, 2020 13:26
@adangel adangel added the in:ast About the AST structure or API, the parsing step label Jan 13, 2023
@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.

[java] Allow @SuppressWarnings with constants instead of literals

2 participants