Skip to content

Commit

Permalink
#27: Set 'externalInfoUrl' to all rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dgroup committed Feb 7, 2022
1 parent bbbfc7f commit ca77ac5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@
</example>
</rule>

<rule name="UseConstantForMetricAnnotation"
<rule name="UseConstantAsMetricName"
since="0.1.0"
language="java"
message="TBD"
externalInfoUrl="https://github.com/dgroup/arch4u-pmd/discussions/75"
message="Use constant for metric name instead of hardcoded string literals: https://github.com/dgroup/arch4u-pmd/discussions/75"
class="net.sourceforge.pmd.lang.rule.XPathRule">
<description>
TBD
The monitoring metric name should be provided into annotation @Timed by constant, not a hardcoded string.
</description>
<priority>3</priority>
<properties>
Expand All @@ -85,14 +86,17 @@
<![CDATA[
import io.micrometer.core.annotation.Timed;
public class Foo {
@RestController
public class MyController {
@Timed("value")
public void bar() {
@Timed(Metrics.ORDER_PROCESSING_DURATION) // ok
public X process(Order order) {
...
}
@Timed(value="value")
public void baz() {
@Timed("order_processing_duration") // violation
public X process(Order order) {
...
}
}
]]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@
* @since 0.1.0
*/
@SuppressWarnings({"PMD.TestClassWithoutTestCases", "PMD.JUnit4TestShouldUseBeforeAnnotation"})
public final class UseConstantForMetricAnnotationTest extends SimpleAggregatorTst {
public final class UseConstantAsMetricNameTest extends SimpleAggregatorTst {

@Override
public void setUp() {
addRule(
"io/github/dgroup/arch4u/pmd/arch4u-ruleset.xml",
"UseConstantForMetricAnnotation"
);
addRule("io/github/dgroup/arch4u/pmd/arch4u-ruleset.xml", "UseConstantAsMetricName");
}
}

0 comments on commit ca77ac5

Please sign in to comment.