Rules that are related to code documentation.
ApexDoc
Since: PMD 6.8.0
Priority: Medium (3)
This rule validates that:
- ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes).
- ApexDoc comments are present for classes, methods, and properties that are protected or private, depending
on the properties
reportPrivate
andreportProtected
. - ApexDoc comments should contain @description depending on the property
reportMissingDescription
. - ApexDoc comments on non-void, non-constructor methods should contain @return.
- ApexDoc comments on void or constructor methods should not contain @return.
- ApexDoc comments on methods with parameters should contain @param for each parameter, in the same order as the method signature.
- ApexDoc comments are present on properties is only validated, if the property
reportProperty
is enabled. By settingreportProperty
to false, you can ignore missing comments on properties.
Method overrides and tests are both exempted from having ApexDoc.
This rule is defined by the following Java class: net.sourceforge.pmd.lang.apex.rule.documentation.ApexDocRule
Example(s):
/**
* @description Hello World
*/
public class HelloWorld {
/**
* @description Bar
* @return Bar
*/
public Object bar() { return null; }
}
This rule has the following properties:
Name | Default Value | Description | Multivalued |
---|---|---|---|
cc_categories | Style | Deprecated Code Climate Categories | yes. Delimiter is ‘|’. |
cc_remediation_points_multiplier | 1 | Deprecated Code Climate Remediation Points multiplier | no |
cc_block_highlighting | false | Deprecated Code Climate Block Highlighting | no |
reportPrivate | false | Report private classes, methods and properties | no |
reportProtected | false | Report protected classes, methods and properties | no |
reportMissingDescription | true | Report missing @description | no |
reportProperty | true | Report properties without comments | no |
Use this rule with the default properties by just referencing it:
<rule ref="category/apex/documentation.xml/ApexDoc" />
Use this rule and customize it:
<rule ref="category/apex/documentation.xml/ApexDoc">
<properties>
<property name="reportPrivate" value="false" />
<property name="reportProtected" value="false" />
<property name="reportMissingDescription" value="true" />
<property name="reportProperty" value="true" />
</properties>
</rule>