Author: dennisl
Date: Wed Nov 8 14:35:22 2006
New Revision: 472667
URL: http://svn.apache.org/viewvc?view=rev&rev=472667
Log:
[MCHECKSTYLE-41] Rules summary count of duplicate JavadocMethod configurations
are merged
o Check for severity level in countRuleViolation().
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java
Modified:
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java?view=diff&rev=472667&r1=472666&r2=472667
==============================================================================
---
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java
(original)
+++
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java
Wed Nov 8 14:35:22 2006
@@ -227,6 +227,11 @@
return ret;
}
+ /**
+ * Create the rules summary section of the report.
+ *
+ * @param results The results to summarize
+ */
private void doRulesSummary( CheckstyleResults results )
{
if ( checkstyleConfig == null )
@@ -274,6 +279,12 @@
sink.section1_();
}
+ /**
+ * Create a summary for each Checkstyle rule.
+ *
+ * @param configChildren Configurations for each Checkstyle rule
+ * @param results The results to summarize
+ */
private void doRuleChildren( Configuration configChildren[],
CheckstyleResults results )
{
for ( int cci = 0; cci < configChildren.length; cci++ )
@@ -292,6 +303,13 @@
}
}
+ /**
+ * Create a summary for one Checkstyle rule.
+ *
+ * @param checkerConfig Configuration for the Checkstyle rule
+ * @param ruleName The name of the rule, for example "JavadocMethod"
+ * @param results The results to summarize
+ */
private void doRuleRow( Configuration checkerConfig, String ruleName,
CheckstyleResults results )
{
sink.tableRow();
@@ -351,11 +369,14 @@
sink.tableCell();
String fixedmessage = getConfigAttribute( checkerConfig, "message",
null );
- sink.text( countRuleViolation( results.getFiles().values().iterator(),
ruleName, fixedmessage ) );
+ // Grab the severity from the rule configuration, use null as default
value
+ String configSeverity = getConfigAttribute( checkerConfig, "severity",
null );
+ sink.text( countRuleViolation( results.getFiles().values().iterator(),
ruleName, fixedmessage, configSeverity ) );
sink.tableCell_();
sink.tableCell();
- String configSeverity = getConfigAttribute( checkerConfig, "severity",
"error" );
+ // Grab the severity again from the rule configuration, this time use
error as default value
+ configSeverity = getConfigAttribute( checkerConfig, "severity",
"error" );
iconSeverity( configSeverity );
sink.nonBreakingSpace();
sink.text( StringUtils.capitalise( configSeverity ) );
@@ -394,7 +415,16 @@
return ret;
}
- private String countRuleViolation( Iterator files, String ruleName, String
message )
+ /**
+ * Count the number of violations for the given rule.
+ *
+ * @param files An iterator over the set of files that has violations
+ * @param ruleName The name of the rule
+ * @param message A message that, if it's not null, will be matched to the
message from the violation
+ * @param severity A severity that, if it's not null, will be matched to
the severity from the violation
+ * @return The number of rule violations
+ */
+ private String countRuleViolation( Iterator files, String ruleName, String
message, String severity )
{
long count = 0;
String sourceName;
@@ -429,6 +459,17 @@
String msgWithoutSingleQuote = StringUtils.replace(
message, "'", "" );
if ( message.equals( event.getMessage() )
|| msgWithoutSingleQuote.equals(
event.getMessage() ) )
+ {
+ count++;
+ }
+ }
+ // Check the severity. This helps to distinguish between
+ // different configurations for the same rule, where each
+ // configuration has a different severity, like
JavadocMetod.
+ // See also http://jira.codehaus.org/browse/MCHECKSTYLE-41
+ else if ( severity != null )
+ {
+ if ( severity.equals(
event.getSeverityLevel().getName() ) )
{
count++;
}