40
40
41
41
/**
42
42
* Generate a report based on CheckstyleResults.
43
- *
44
- *
45
43
*/
46
44
public class CheckstyleReportRenderer extends AbstractMavenReportRenderer {
47
45
private static final int NO_TEXT = 0 ;
@@ -120,6 +118,7 @@ private String getI18nString(String key) {
120
118
return i18n .getString ("checkstyle-report" , locale , "report.checkstyle." + key );
121
119
}
122
120
121
+ @ Override
123
122
protected void renderBody () {
124
123
startSection (getTitle ());
125
124
@@ -150,31 +149,31 @@ protected void renderBody() {
150
149
}
151
150
152
151
/**
153
- * Get the value of the specified attribute from the Checkstyle configuration.
152
+ * Get the value of the specified property from the Checkstyle configuration.
154
153
* If parentConfigurations is non-null and non-empty, the parent
155
- * configurations are searched if the attribute cannot be found in the
156
- * current configuration. If the attribute is still not found, the
154
+ * configurations are searched if the property cannot be found in the
155
+ * current configuration. If the property is still not found, the
157
156
* specified default value will be returned.
158
157
*
159
- * @param config The current Checkstyle configuration
160
- * @param parentConfiguration The configuration of the parent of the current configuration
161
- * @param attributeName The name of the attribute
162
- * @param defaultValue The default value to use if the attribute cannot be found in any configuration
163
- * @return The value of the specified attribute
158
+ * @param config the current Checkstyle configuration
159
+ * @param parentConfiguration the configuration of the parent of the current configuration
160
+ * @param propertyName the name of the property
161
+ * @param defaultValue the default value to use if the property cannot be found in any configuration
162
+ * @return the value of the specified property
164
163
*/
165
- private String getConfigAttribute (
164
+ private String getConfigProperty (
166
165
Configuration config ,
167
166
ChainedItem <Configuration > parentConfiguration ,
168
- String attributeName ,
167
+ String propertyName ,
169
168
String defaultValue ) {
170
169
String ret ;
171
170
try {
172
- ret = config .getAttribute ( attributeName );
171
+ ret = config .getProperty ( propertyName );
173
172
} catch (CheckstyleException e ) {
174
- // Try to find the attribute in a parent, if there are any
173
+ // Try to find the property in a parent, if there are any
175
174
if (parentConfiguration != null ) {
176
- ret = getConfigAttribute (
177
- parentConfiguration .value , parentConfiguration .parent , attributeName , defaultValue );
175
+ ret = getConfigProperty (
176
+ parentConfiguration .value , parentConfiguration .parent , propertyName , defaultValue );
178
177
} else {
179
178
ret = defaultValue ;
180
179
}
@@ -185,7 +184,7 @@ private String getConfigAttribute(
185
184
/**
186
185
* Create the rules summary section of the report.
187
186
*
188
- * @param results The results to summarize
187
+ * @param results the results to summarize
189
188
*/
190
189
private void renderRulesSummarySection () {
191
190
if (!enableRulesSummary ) {
@@ -256,16 +255,16 @@ private void renderRuleRow(ConfReference ref, CheckstyleResults results, String
256
255
sink .text (ruleName );
257
256
}
258
257
259
- List <String > attribnames = new ArrayList <>(Arrays .asList (checkerConfig .getAttributeNames ()));
260
- attribnames .remove ("severity" ); // special value (deserves unique column)
261
- if (!attribnames .isEmpty ()) {
258
+ List <String > propertyNames = new ArrayList <>(Arrays .asList (checkerConfig .getPropertyNames ()));
259
+ propertyNames .remove ("severity" ); // special value (deserves unique column)
260
+ if (!propertyNames .isEmpty ()) {
262
261
sink .list ();
263
- for (String name : attribnames ) {
262
+ for (String name : propertyNames ) {
264
263
sink .listItem ();
265
264
266
265
sink .text (name );
267
266
268
- String value = getConfigAttribute (checkerConfig , null , name , "" );
267
+ String value = getConfigProperty (checkerConfig , null , name , "" );
269
268
// special case, Header.header and RegexpHeader.header
270
269
if ("header" .equals (name ) && ("Header" .equals (ruleName ) || "RegexpHeader" .equals (ruleName ))) {
271
270
String [] lines = StringUtils .split (value , "\\ n" );
@@ -316,7 +315,7 @@ private void renderRuleRow(ConfReference ref, CheckstyleResults results, String
316
315
sink .tableCell ();
317
316
// Grab the severity from the rule configuration, this time use error as default value
318
317
// Also pass along all parent configurations, so that we can try to find the severity there
319
- String severity = getConfigAttribute (checkerConfig , parentConfiguration , "severity" , "error" );
318
+ String severity = getConfigProperty (checkerConfig , parentConfiguration , "severity" , "error" );
320
319
iconSeverity (severity , TEXT_SIMPLE );
321
320
sink .tableCell_ ();
322
321
@@ -626,11 +625,11 @@ private void sortConfiguration(
626
625
// special sub-case: TreeWalker is the parent of multiple rules, not an effective rule
627
626
sortConfiguration (result , childConfig , new ChainedItem <>(config , parent ), results );
628
627
} else {
629
- String fixedmessage = getConfigAttribute (childConfig , null , "message" , null );
628
+ String fixedmessage = getConfigProperty (childConfig , null , "message" , null );
630
629
// Grab the severity from the rule configuration. Do not set default value here as
631
630
// it breaks our rule aggregate section entirely. The counts are off but this is
632
631
// not appropriate fix location per MCHECKSTYLE-365.
633
- String configSeverity = getConfigAttribute (childConfig , null , "severity" , null );
632
+ String configSeverity = getConfigProperty (childConfig , null , "severity" , null );
634
633
635
634
// count rule violations
636
635
long violations = 0 ;
@@ -674,6 +673,7 @@ private static class ConfReference implements Comparable<ConfReference> {
674
673
this .count = count ;
675
674
}
676
675
676
+ @ Override
677
677
public int compareTo (ConfReference o ) {
678
678
int compare = category .compareTo (o .category );
679
679
if (compare == 0 ) {
0 commit comments