Comments

Rules intended to catch errors related to code comments

CommentRequired

Since: PMD 5.1

Denotes whether comments are required (or unwanted) for specific language elements.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.comments.CommentRequiredRule

Example(s):

/**
* 
*
* @author George Bush
*/

    

This rule has the following properties:

Name Default Value Description
violationSuppressRegex Suppress violations with messages matching a regular expression
violationSuppressXPath Suppress violations on nodes which match a given relative XPath expression.
enumCommentRequirement Required Enum comments. Possible values: [Required, Ignored, Unwanted]
protectedMethodCommentRequirement Required Protected method constructor comments. Possible values: [Required, Ignored, Unwanted]
publicMethodCommentRequirement Required Public method and constructor comments. Possible values: [Required, Ignored, Unwanted]
fieldCommentRequirement Required Field comments. Possible values: [Required, Ignored, Unwanted]
headerCommentRequirement Required Header comments. Possible values: [Required, Ignored, Unwanted]

CommentSize

Since: PMD 5.0

Determines whether the dimensions of non-header comments found are within the specified limits.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.comments.CommentSizeRule

Example(s):

/**
*
*	too many lines!
*
*
*
*
*
*
*
*
*
*
*
*
*/

    

This rule has the following properties:

Name Default Value Description
violationSuppressRegex Suppress violations with messages matching a regular expression
violationSuppressXPath Suppress violations on nodes which match a given relative XPath expression.
maxLines 6 Maximum lines
maxLineLength 80 Maximum line length

CommentContent

Since: PMD 5.0

A rule for the politically correct... we don't want to offend anyone.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.comments.CommentContentRule

Example(s):
      
//	OMG, this is horrible, Bob is an idiot !!!
      
  

This rule has the following properties:

Name Default Value Description
violationSuppressRegex Suppress violations with messages matching a regular expression
violationSuppressXPath Suppress violations on nodes which match a given relative XPath expression.
disallowedTerms [idiot, jerk] Illegal terms or phrases
caseSensitive false Case sensitive
wordsAreRegex false Use regular expressions