Class CheckstyleReportRenderer
- java.lang.Object
-
- org.apache.maven.reporting.AbstractMavenReportRenderer
-
- org.apache.maven.plugins.checkstyle.CheckstyleReportRenderer
-
- All Implemented Interfaces:
org.apache.maven.reporting.MavenReportRenderer
public class CheckstyleReportRenderer extends org.apache.maven.reporting.AbstractMavenReportRenderer
Generate a report based on CheckstyleResults.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CheckstyleReportRenderer.ChainedItem<T>
private static class
CheckstyleReportRenderer.ConfReference
-
Field Summary
Fields Modifier and Type Field Description private com.puppycrawl.tools.checkstyle.api.Configuration
checkstyleConfig
private boolean
enableFilesSummary
private boolean
enableRulesSummary
private boolean
enableSeveritySummary
private org.codehaus.plexus.i18n.I18N
i18n
private java.util.Locale
locale
private static int
NO_TEXT
private org.apache.maven.project.MavenProject
project
private CheckstyleResults
results
private java.lang.String
ruleset
private org.apache.maven.doxia.tools.SiteTool
siteTool
private java.util.List<java.io.File>
testSourceDirectories
private static int
TEXT_ABBREV
private static int
TEXT_SIMPLE
private static int
TEXT_TITLE
private java.util.List<java.lang.String>
treeWalkerNames
private java.lang.String
xrefLocation
private java.lang.String
xrefTestLocation
-
Constructor Summary
Constructors Constructor Description CheckstyleReportRenderer(org.apache.maven.doxia.sink.Sink sink, org.codehaus.plexus.i18n.I18N i18n, java.util.Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.doxia.tools.SiteTool siteTool, java.lang.String ruleset, java.lang.String xrefLocation, java.lang.String xrefTestLocation, java.util.List<java.io.File> testSourceDirectories, boolean enableRulesSummary, boolean enableSeveritySummary, boolean enableFilesSummary, CheckstyleResults results)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
getCheckstyleVersion()
Get the effective Checkstyle version at runtime.private java.lang.String
getConfigAttribute(com.puppycrawl.tools.checkstyle.api.Configuration config, CheckstyleReportRenderer.ChainedItem<com.puppycrawl.tools.checkstyle.api.Configuration> parentConfiguration, java.lang.String attributeName, java.lang.String defaultValue)
Get the value of the specified attribute from the Checkstyle configuration.private java.lang.String
getEffectiveXrefLocation(java.util.List<com.puppycrawl.tools.checkstyle.api.AuditEvent> eventList)
private java.lang.String
getI18nString(java.lang.String key)
java.lang.String
getTitle()
private void
iconSeverity(java.lang.String level, int textType)
Render an icon of given level with associated text.private boolean
isTestSource(java.lang.String absoluteFilename)
boolean
matchRule(com.puppycrawl.tools.checkstyle.api.AuditEvent event, java.lang.String ruleName, java.lang.String expectedMessage, java.lang.String expectedSeverity)
Check if a violation matches a rule.protected void
renderBody()
private void
renderDetailsSection()
private void
renderFileEvents(java.util.List<com.puppycrawl.tools.checkstyle.api.AuditEvent> eventList, java.lang.String filename)
private void
renderFilesSummarySection()
private void
renderRuleRow(CheckstyleReportRenderer.ConfReference ref, CheckstyleResults results, java.lang.String previousCategory)
Create a summary for one Checkstyle rule.private void
renderRulesSummarySection()
Create the rules summary section of the report.private void
renderSeveritySummarySection()
void
setTreeWalkerNames(java.util.List<java.lang.String> treeWalkerNames)
private void
sortConfiguration(java.util.List<CheckstyleReportRenderer.ConfReference> result, com.puppycrawl.tools.checkstyle.api.Configuration config, CheckstyleReportRenderer.ChainedItem<com.puppycrawl.tools.checkstyle.api.Configuration> parent, CheckstyleResults results)
java.util.List<CheckstyleReportRenderer.ConfReference>
sortConfiguration(CheckstyleResults results)
-
Methods inherited from class org.apache.maven.reporting.AbstractMavenReportRenderer
createLinkPatternedText, endSection, endTable, javaScript, link, linkPatternedText, paragraph, propertiesToString, render, startSection, startSection, startTable, startTable, tableCaption, tableCell, tableCell, tableHeader, tableHeaderCell, tableRow, text, verbatimLink, verbatimSource, verbatimText
-
-
-
-
Field Detail
-
NO_TEXT
private static final int NO_TEXT
- See Also:
- Constant Field Values
-
TEXT_SIMPLE
private static final int TEXT_SIMPLE
- See Also:
- Constant Field Values
-
TEXT_TITLE
private static final int TEXT_TITLE
- See Also:
- Constant Field Values
-
TEXT_ABBREV
private static final int TEXT_ABBREV
- See Also:
- Constant Field Values
-
i18n
private final org.codehaus.plexus.i18n.I18N i18n
-
locale
private final java.util.Locale locale
-
project
private final org.apache.maven.project.MavenProject project
-
checkstyleConfig
private final com.puppycrawl.tools.checkstyle.api.Configuration checkstyleConfig
-
enableRulesSummary
private final boolean enableRulesSummary
-
enableSeveritySummary
private final boolean enableSeveritySummary
-
enableFilesSummary
private final boolean enableFilesSummary
-
siteTool
private final org.apache.maven.doxia.tools.SiteTool siteTool
-
xrefLocation
private java.lang.String xrefLocation
-
xrefTestLocation
private java.lang.String xrefTestLocation
-
testSourceDirectories
private java.util.List<java.io.File> testSourceDirectories
-
treeWalkerNames
private java.util.List<java.lang.String> treeWalkerNames
-
ruleset
private final java.lang.String ruleset
-
results
private final CheckstyleResults results
-
-
Constructor Detail
-
CheckstyleReportRenderer
public CheckstyleReportRenderer(org.apache.maven.doxia.sink.Sink sink, org.codehaus.plexus.i18n.I18N i18n, java.util.Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.doxia.tools.SiteTool siteTool, java.lang.String ruleset, java.lang.String xrefLocation, java.lang.String xrefTestLocation, java.util.List<java.io.File> testSourceDirectories, boolean enableRulesSummary, boolean enableSeveritySummary, boolean enableFilesSummary, CheckstyleResults results)
-
-
Method Detail
-
getTitle
public java.lang.String getTitle()
- Specified by:
getTitle
in interfaceorg.apache.maven.reporting.MavenReportRenderer
- Specified by:
getTitle
in classorg.apache.maven.reporting.AbstractMavenReportRenderer
-
getI18nString
private java.lang.String getI18nString(java.lang.String key)
- Parameters:
key
- The key.- Returns:
- The translated string.
-
renderBody
protected void renderBody()
- Specified by:
renderBody
in classorg.apache.maven.reporting.AbstractMavenReportRenderer
-
getConfigAttribute
private java.lang.String getConfigAttribute(com.puppycrawl.tools.checkstyle.api.Configuration config, CheckstyleReportRenderer.ChainedItem<com.puppycrawl.tools.checkstyle.api.Configuration> parentConfiguration, java.lang.String attributeName, java.lang.String defaultValue)
Get the value of the specified attribute from the Checkstyle configuration. If parentConfigurations is non-null and non-empty, the parent configurations are searched if the attribute cannot be found in the current configuration. If the attribute is still not found, the specified default value will be returned.- Parameters:
config
- The current Checkstyle configurationparentConfiguration
- The configuration of the parent of the current configurationattributeName
- The name of the attributedefaultValue
- The default value to use if the attribute cannot be found in any configuration- Returns:
- The value of the specified attribute
-
renderRulesSummarySection
private void renderRulesSummarySection()
Create the rules summary section of the report.- Parameters:
results
- The results to summarize
-
renderRuleRow
private void renderRuleRow(CheckstyleReportRenderer.ConfReference ref, CheckstyleResults results, java.lang.String previousCategory)
Create a summary for one Checkstyle rule.- Parameters:
ref
- The configuration reference for the rowresults
- The results to summarizepreviousCategory
- The previous row's category
-
matchRule
public boolean matchRule(com.puppycrawl.tools.checkstyle.api.AuditEvent event, java.lang.String ruleName, java.lang.String expectedMessage, java.lang.String expectedSeverity)
Check if a violation matches a rule.- Parameters:
event
- the violation to checkruleName
- The name of the ruleexpectedMessage
- A message that, if it's not null, will be matched to the message from the violationexpectedSeverity
- A severity that, if it's not null, will be matched to the severity from the violation- Returns:
- The number of rule violations
-
renderSeveritySummarySection
private void renderSeveritySummarySection()
-
renderFilesSummarySection
private void renderFilesSummarySection()
-
renderDetailsSection
private void renderDetailsSection()
-
renderFileEvents
private void renderFileEvents(java.util.List<com.puppycrawl.tools.checkstyle.api.AuditEvent> eventList, java.lang.String filename)
-
getEffectiveXrefLocation
private java.lang.String getEffectiveXrefLocation(java.util.List<com.puppycrawl.tools.checkstyle.api.AuditEvent> eventList)
-
isTestSource
private boolean isTestSource(java.lang.String absoluteFilename)
-
setTreeWalkerNames
public void setTreeWalkerNames(java.util.List<java.lang.String> treeWalkerNames)
-
iconSeverity
private void iconSeverity(java.lang.String level, int textType)
Render an icon of given level with associated text.- Parameters:
level
- one ofINFO
,WARNING
orERROR
constantstextType
- one ofNO_TEXT
,TEXT_SIMPLE
,TEXT_TITLE
orTEXT_ABBREV
constants
-
getCheckstyleVersion
private java.lang.String getCheckstyleVersion()
Get the effective Checkstyle version at runtime.- Returns:
- the MANIFEST implementation version of Checkstyle API package (can be
null
)
-
sortConfiguration
public java.util.List<CheckstyleReportRenderer.ConfReference> sortConfiguration(CheckstyleResults results)
-
sortConfiguration
private void sortConfiguration(java.util.List<CheckstyleReportRenderer.ConfReference> result, com.puppycrawl.tools.checkstyle.api.Configuration config, CheckstyleReportRenderer.ChainedItem<com.puppycrawl.tools.checkstyle.api.Configuration> parent, CheckstyleResults results)
-
-