[core] Implement violation decorators#4050
Conversation
Generated by 🚫 Danger |
7b24358 to
099c46c
Compare
099c46c to
4b5575e
Compare
|
Regression: AvoidUsingHardCodedIP violation message is |
adangel
left a comment
There was a problem hiding this comment.
Thanks!
I'll fix the issues and merge it afterwards.
| maybeAdd("class", rv.getAdditionalInfo().get(RuleViolation.CLASS_NAME)); | ||
| maybeAdd("method", rv.getAdditionalInfo().get(RuleViolation.METHOD_NAME)); | ||
| maybeAdd("variable", rv.getAdditionalInfo().get(RuleViolation.VARIABLE_NAME)); | ||
| // todo other additional info keys are not rendered |
There was a problem hiding this comment.
rendering additional info keys in XML renderer requires to open up the schema to allow arbitrary attributes. currently these attributes (package, class, method, variable) are declared explicitly. This could be achieved by adding anyAttribute (https://www.w3schools.com/xml/schema_complex_anyattribute.asp).
| <expected-messages> | ||
| <message>Do not hard code the IP address badIdea</message> | ||
| </expected-messages> |
There was a problem hiding this comment.
Seems this was never tested before... and it doesn't work on PMD6 either.
The undocumented feature of referencing ${variableName} is only used by 3 rules: AvoidUsingHardCodedIP, RedundantFieldInitializer, JUnitTestContainsTooManyAsserts
Ok, it turns out, that it doesn't work only for AvoidUsingHardCodedIP - the reported node is a ASTLiteral, which is not considered in PMD6. But here, we consider it as a ASTExpression and search the parent axis for variable names.
I'd keep it on PMD6 as is and consider this as a bugfix for PMD 7.
[core] Implement violation decorators #4050
Describe the PR
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)