You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/05/17 19:52:20 UTC
[maven-checkstyle-plugin] 01/01: [MCHECKSTYLE-436] Replace CheckstyleReportGenerator with a new CheckstyleReportRenderer
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch MCHECKSTYLE-436
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git
commit 702d5789bcbbba6a872f9e4f4dd893ae06d5f250
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Mon May 15 22:07:22 2023 +0200
[MCHECKSTYLE-436] Replace CheckstyleReportGenerator with a new CheckstyleReportRenderer
This closes #118
---
pom.xml | 11 +
.../checkstyle/AbstractCheckstyleReport.java | 91 +++--
...enerator.java => CheckstyleReportRenderer.java} | 424 ++++++++-------------
.../apache/maven/plugins/checkstyle/IconTool.java | 133 -------
src/main/resources/checkstyle-report.properties | 1 -
src/main/resources/checkstyle-report_de.properties | 1 -
src/main/resources/checkstyle-report_fr.properties | 1 -
.../resources/checkstyle-report_pt_BR.properties | 1 -
src/main/resources/checkstyle-report_sv.properties | 1 -
.../plugins/checkstyle/CheckstyleReportTest.java | 2 +-
10 files changed, 221 insertions(+), 445 deletions(-)
diff --git a/pom.xml b/pom.xml
index baf1e0f..ec71de0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -172,6 +172,17 @@ under the License.
<artifactId>plexus-utils</artifactId>
<version>3.5.1</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-i18n</artifactId>
+ <version>1.0-beta-10</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<!-- checkstyle -->
<dependency>
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
index 3f55bef..0e39ecf 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
@@ -28,7 +28,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.ResourceBundle;
import com.puppycrawl.tools.checkstyle.DefaultLogger;
import com.puppycrawl.tools.checkstyle.XMLLogger;
@@ -53,6 +52,7 @@ import org.apache.maven.plugins.checkstyle.exec.CheckstyleResults;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.FileResourceLoader;
import org.codehaus.plexus.util.FileUtils;
@@ -438,16 +438,31 @@ public abstract class AbstractCheckstyleReport extends AbstractMavenReport {
@Component(role = CheckstyleExecutor.class, hint = "default")
protected CheckstyleExecutor checkstyleExecutor;
+ /**
+ * Internationalization component
+ */
+ @Component
+ private I18N i18n;
+
protected ByteArrayOutputStream stringOutputStream;
/** {@inheritDoc} */
public String getName(Locale locale) {
- return getBundle(locale).getString("report.checkstyle.name");
+ return getI18nString(locale, "name");
}
/** {@inheritDoc} */
public String getDescription(Locale locale) {
- return getBundle(locale).getString("report.checkstyle.description");
+ return getI18nString(locale, "description");
+ }
+
+ /**
+ * @param locale The locale
+ * @param key The key to search for
+ * @return The text appropriate for the locale.
+ */
+ protected String getI18nString(Locale locale, String key) {
+ return i18n.getString("checkstyle-report", locale, "report.checkstyle." + key);
}
/** {@inheritDoc} */
@@ -495,8 +510,34 @@ public abstract class AbstractCheckstyleReport extends AbstractMavenReport {
CheckstyleResults results = checkstyleExecutor.executeCheckstyle(request);
- ResourceBundle bundle = getBundle(locale);
- generateMainReport(results, bundle, effectiveConfigLocation);
+ CheckstyleReportRenderer r = new CheckstyleReportRenderer(
+ getSink(),
+ i18n,
+ locale,
+ project,
+ siteTool,
+ effectiveConfigLocation,
+ enableRulesSummary,
+ enableSeveritySummary,
+ enableFilesSummary,
+ results);
+ if (linkXRef) {
+ initializeXrefLocation(r);
+ if (r.getXrefLocation() == null && results.getFileCount() > 0) {
+ getLog().warn("Unable to locate Source XRef to link to - DISABLED");
+ }
+
+ initializeXrefTestLocation(r);
+ if (r.getXrefTestLocation() == null && results.getFileCount() > 0) {
+ getLog().warn("Unable to locate Test Source XRef to link to - DISABLED");
+ }
+
+ r.setTestSourceDirectories(getTestSourceDirectories());
+ }
+ if (treeWalkerNames != null) {
+ r.setTreeWalkerNames(treeWalkerNames);
+ }
+ r.render();
} catch (CheckstyleException e) {
throw new MavenReportException("Failed during checkstyle configuration", e);
} catch (CheckstyleExecutorException e) {
@@ -617,49 +658,21 @@ public abstract class AbstractCheckstyleReport extends AbstractMavenReport {
return consoleListener;
}
- private void generateMainReport(CheckstyleResults results, ResourceBundle bundle, String configLocation) {
- CheckstyleReportGenerator generator =
- new CheckstyleReportGenerator(getSink(), bundle, project.getBasedir(), siteTool, configLocation);
-
- generator.setLog(getLog());
- generator.setEnableRulesSummary(enableRulesSummary);
- generator.setEnableSeveritySummary(enableSeveritySummary);
- generator.setEnableFilesSummary(enableFilesSummary);
- generator.setCheckstyleConfig(results.getConfiguration());
- if (linkXRef) {
- initializeXrefLocation(generator);
- if (generator.getXrefLocation() == null && results.getFileCount() > 0) {
- getLog().warn("Unable to locate Source XRef to link to - DISABLED");
- }
-
- initializeXrefTestLocation(generator);
- if (generator.getXrefTestLocation() == null && results.getFileCount() > 0) {
- getLog().warn("Unable to locate Test Source XRef to link to - DISABLED");
- }
-
- generator.setTestSourceDirectories(getTestSourceDirectories());
- }
- if (treeWalkerNames != null) {
- generator.setTreeWalkerNames(treeWalkerNames);
- }
- generator.generateReport(results);
- }
-
- private void initializeXrefLocation(CheckstyleReportGenerator generator) {
+ private void initializeXrefLocation(CheckstyleReportRenderer renderer) {
String relativePath = determineRelativePath(xrefLocation);
if (xrefLocation.exists() || checkMavenJxrPluginIsConfigured()) {
// XRef was already generated by manual execution of a lifecycle binding
// the report is on its way
- generator.setXrefLocation(relativePath);
+ renderer.setXrefLocation(relativePath);
}
}
- private void initializeXrefTestLocation(CheckstyleReportGenerator generator) {
+ private void initializeXrefTestLocation(CheckstyleReportRenderer renderer) {
String relativePath = determineRelativePath(xrefTestLocation);
if (xrefTestLocation.exists() || checkMavenJxrPluginIsConfigured()) {
// XRef was already generated by manual execution of a lifecycle binding
// the report is on its way
- generator.setXrefTestLocation(relativePath);
+ renderer.setXrefTestLocation(relativePath);
}
}
@@ -683,10 +696,6 @@ public abstract class AbstractCheckstyleReport extends AbstractMavenReport {
return false;
}
- private static ResourceBundle getBundle(Locale locale) {
- return ResourceBundle.getBundle("checkstyle-report", locale, AbstractCheckstyleReport.class.getClassLoader());
- }
-
protected List<File> getSourceDirectories() {
if (sourceDirectories == null) {
sourceDirectories = project.getCompileSourceRoots();
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportGenerator.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
similarity index 67%
rename from src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportGenerator.java
rename to src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
index cbc710d..07039cd 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.ResourceBundle;
+import java.util.Locale;
import com.puppycrawl.tools.checkstyle.api.AuditEvent;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
@@ -31,36 +31,37 @@ import com.puppycrawl.tools.checkstyle.api.Configuration;
import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.SinkEventAttributes;
-import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.apache.maven.doxia.tools.SiteTool;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.apache.maven.doxia.util.DoxiaUtils;
import org.apache.maven.plugins.checkstyle.exec.CheckstyleResults;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReportRenderer;
+import org.codehaus.plexus.i18n.I18N;
/**
* Generate a report based on CheckstyleResults.
*
*
*/
-public class CheckstyleReportGenerator {
- private Log log;
+public class CheckstyleReportRenderer extends AbstractMavenReportRenderer {
+ private static final int NO_TEXT = 0;
+ private static final int TEXT_SIMPLE = 1;
+ private static final int TEXT_TITLE = 2;
+ private static final int TEXT_ABBREV = 3;
- private final File basedir;
+ private final I18N i18n;
- private final ResourceBundle bundle;
+ private final Locale locale;
- private final Sink sink;
+ private final MavenProject project;
- private SeverityLevel severityLevel;
+ private final Configuration checkstyleConfig;
- private Configuration checkstyleConfig;
+ private final boolean enableRulesSummary;
- private boolean enableRulesSummary;
+ private final boolean enableSeveritySummary;
- private boolean enableSeveritySummary;
-
- private boolean enableFilesSummary;
+ private final boolean enableFilesSummary;
private final SiteTool siteTool;
@@ -72,90 +73,52 @@ public class CheckstyleReportGenerator {
private List<String> treeWalkerNames = Collections.singletonList("TreeWalker");
- private final IconTool iconTool;
-
private final String ruleset;
- public CheckstyleReportGenerator(
- Sink sink, ResourceBundle bundle, File basedir, SiteTool siteTool, String ruleset) {
- this.bundle = bundle;
-
- this.sink = sink;
-
- this.basedir = basedir;
-
+ private final CheckstyleResults results;
+
+ public CheckstyleReportRenderer(
+ Sink sink,
+ I18N i18n,
+ Locale locale,
+ MavenProject project,
+ SiteTool siteTool,
+ String ruleset,
+ boolean enableRulesSummary,
+ boolean enableSeveritySummary,
+ boolean enableFilesSummary,
+ CheckstyleResults results) {
+ super(sink);
+ this.i18n = i18n;
+ this.locale = locale;
+ this.project = project;
this.siteTool = siteTool;
-
this.ruleset = ruleset;
-
- this.enableRulesSummary = true;
- this.enableSeveritySummary = true;
- this.enableFilesSummary = true;
- this.iconTool = new IconTool(sink, bundle);
- }
-
- public Log getLog() {
- if (this.log == null) {
- this.log = new SystemStreamLog();
- }
- return this.log;
- }
-
- public void setLog(Log log) {
- this.log = log;
+ this.enableRulesSummary = enableRulesSummary;
+ this.enableSeveritySummary = enableSeveritySummary;
+ this.enableFilesSummary = enableFilesSummary;
+ this.results = results;
+ this.checkstyleConfig = results.getConfiguration();
}
- private String getTitle() {
- String title;
-
- if (getSeverityLevel() == null) {
- title = bundle.getString("report.checkstyle.title");
- } else {
- title = bundle.getString("report.checkstyle.severity_title") + severityLevel.getName();
- }
-
- return title;
+ @Override
+ public String getTitle() {
+ return getI18nString("title");
}
- public void generateReport(CheckstyleResults results) {
- doHeading();
-
- if (getSeverityLevel() == null) {
- if (enableSeveritySummary) {
- doSeveritySummary(results);
- }
-
- if (enableFilesSummary) {
- doFilesSummary(results);
- }
-
- if (enableRulesSummary) {
- doRulesSummary(results);
- }
- }
-
- doDetails(results);
- sink.body_();
- sink.flush();
- sink.close();
+ /**
+ * @param key The key.
+ * @return The translated string.
+ */
+ private String getI18nString(String key) {
+ return i18n.getString("checkstyle-report", locale, "report.checkstyle." + key);
}
- private void doHeading() {
- sink.head();
- sink.title();
- sink.text(getTitle());
- sink.title_();
- sink.head_();
-
- sink.body();
-
- sink.section1();
- sink.sectionTitle1();
- sink.text(getTitle());
- sink.sectionTitle1_();
+ public void renderBody() {
+ startSection(getTitle());
sink.paragraph();
- sink.text(bundle.getString("report.checkstyle.checkstylelink") + " ");
+ sink.text(getI18nString("checkstylelink") + " ");
sink.link("https://checkstyle.org/");
sink.text("Checkstyle");
sink.link_();
@@ -165,11 +128,19 @@ public class CheckstyleReportGenerator {
sink.text(version);
}
sink.text(" ");
- sink.text(String.format(bundle.getString("report.checkstyle.ruleset"), ruleset));
+ sink.text(String.format(getI18nString("ruleset"), ruleset));
sink.text(".");
-
sink.paragraph_();
- sink.section1_();
+
+ renderSeveritySummarySection();
+
+ renderFilesSummarySection();
+
+ renderRulesSummarySection();
+
+ renderDetailsSection();
+
+ endSection();
}
/**
@@ -210,58 +181,40 @@ public class CheckstyleReportGenerator {
*
* @param results The results to summarize
*/
- private void doRulesSummary(CheckstyleResults results) {
+ private void renderRulesSummarySection() {
+ if (!enableRulesSummary) {
+ return;
+ }
if (checkstyleConfig == null) {
return;
}
- sink.section1();
- sink.sectionTitle1();
- sink.text(bundle.getString("report.checkstyle.rules"));
- sink.sectionTitle1_();
-
- sink.table();
- sink.tableRows(null, false);
-
- sink.tableRow();
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.rule.category"));
- sink.tableHeaderCell_();
-
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.rule"));
- sink.tableHeaderCell_();
-
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.violations"));
- sink.tableHeaderCell_();
+ startSection(getI18nString("rules"));
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.column.severity"));
- sink.tableHeaderCell_();
+ startTable();
- sink.tableRow_();
+ tableHeader(new String[] {
+ getI18nString("rule.category"),
+ getI18nString("rule"),
+ getI18nString("violations"),
+ getI18nString("column.severity")
+ });
// Top level should be the checker.
if ("checker".equalsIgnoreCase(checkstyleConfig.getName())) {
String category = null;
for (ConfReference ref : sortConfiguration(results)) {
- doRuleRow(ref, results, category);
+ renderRuleRow(ref, results, category);
category = ref.category;
}
} else {
- sink.tableRow();
- sink.tableCell();
- sink.text(bundle.getString("report.checkstyle.norule"));
- sink.tableCell_();
- sink.tableRow_();
+ tableRow(new String[] {getI18nString("norule")});
}
- sink.tableRows_();
- sink.table_();
+ endTable();
- sink.section1_();
+ endSection();
}
/**
@@ -271,7 +224,7 @@ public class CheckstyleReportGenerator {
* @param results The results to summarize
* @param previousCategory The previous row's category
*/
- private void doRuleRow(ConfReference ref, CheckstyleResults results, String previousCategory) {
+ private void renderRuleRow(ConfReference ref, CheckstyleResults results, String previousCategory) {
Configuration checkerConfig = ref.configuration;
ChainedItem<Configuration> parentConfiguration = ref.parentConfiguration;
String ruleName = checkerConfig.getName();
@@ -325,13 +278,11 @@ public class CheckstyleReportGenerator {
sink.text(": ");
sink.monospaced();
sink.text("\"");
- if (basedir != null) {
- // Make the headerFile value relative to ${basedir}
- String path = siteTool.getRelativePath(value, basedir.getAbsolutePath());
- sink.text(path.replace('\\', '/'));
- } else {
- sink.text(value);
- }
+ // Make the headerFile value relative to ${basedir}
+ String path =
+ siteTool.getRelativePath(value, project.getBasedir().getAbsolutePath());
+ sink.text(path.replace('\\', '/'));
+ sink.text(value);
sink.text("\"");
sink.monospaced_();
} else {
@@ -359,7 +310,7 @@ public class CheckstyleReportGenerator {
// Grab the severity from the rule configuration, this time use error as default value
// Also pass along all parent configurations, so that we can try to find the severity there
String severity = getConfigAttribute(checkerConfig, parentConfiguration, "severity", "error");
- iconTool.iconSeverity(severity, IconTool.TEXT_SIMPLE);
+ iconSeverity(severity, TEXT_SIMPLE);
sink.tableCell_();
sink.tableRow_();
@@ -403,75 +354,66 @@ public class CheckstyleReportGenerator {
return true;
}
- private void doSeveritySummary(CheckstyleResults results) {
- sink.section1();
- sink.sectionTitle1();
- sink.text(bundle.getString("report.checkstyle.summary"));
- sink.sectionTitle1_();
+ private void renderSeveritySummarySection() {
+ if (!enableSeveritySummary) {
+ return;
+ }
+
+ startSection(getI18nString("summary"));
- sink.table();
- sink.tableRows(null, false);
+ startTable();
sink.tableRow();
sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.files"));
+ sink.text(getI18nString("files"));
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconTool.iconInfo(IconTool.TEXT_TITLE);
+ iconSeverity("info", TEXT_TITLE);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconTool.iconWarning(IconTool.TEXT_TITLE);
+ iconSeverity("warning", TEXT_TITLE);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconTool.iconError(IconTool.TEXT_TITLE);
+ iconSeverity("error", TEXT_TITLE);
sink.tableHeaderCell_();
sink.tableRow_();
- sink.tableRow();
- sink.tableCell();
- sink.text(String.valueOf(results.getFileCount()));
- sink.tableCell_();
- sink.tableCell();
- sink.text(String.valueOf(results.getSeverityCount(SeverityLevel.INFO)));
- sink.tableCell_();
- sink.tableCell();
- sink.text(String.valueOf(results.getSeverityCount(SeverityLevel.WARNING)));
- sink.tableCell_();
- sink.tableCell();
- sink.text(String.valueOf(results.getSeverityCount(SeverityLevel.ERROR)));
- sink.tableCell_();
- sink.tableRow_();
+ tableRow(new String[] {
+ String.valueOf(results.getFileCount()),
+ String.valueOf(results.getSeverityCount(SeverityLevel.INFO)),
+ String.valueOf(results.getSeverityCount(SeverityLevel.WARNING)),
+ String.valueOf(results.getSeverityCount(SeverityLevel.ERROR))
+ });
- sink.tableRows_();
- sink.table_();
+ endTable();
- sink.section1_();
+ endSection();
}
- private void doFilesSummary(CheckstyleResults results) {
- sink.section1();
- sink.sectionTitle1();
- sink.text(bundle.getString("report.checkstyle.files"));
- sink.sectionTitle1_();
+ private void renderFilesSummarySection() {
+ if (!enableFilesSummary) {
+ return;
+ }
+
+ startSection(getI18nString("files"));
- sink.table();
- sink.tableRows(null, false);
+ startTable();
sink.tableRow();
sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.file"));
+ sink.text(getI18nString("file"));
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconTool.iconInfo(IconTool.TEXT_ABBREV);
+ iconSeverity("info", TEXT_ABBREV);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconTool.iconWarning(IconTool.TEXT_ABBREV);
+ iconSeverity("warning", TEXT_ABBREV);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconTool.iconError(IconTool.TEXT_ABBREV);
+ iconSeverity("error", TEXT_ABBREV);
sink.tableHeaderCell_();
sink.tableRow_();
@@ -489,7 +431,7 @@ public class CheckstyleReportGenerator {
sink.tableRow();
sink.tableCell();
- sink.link("#" + filename.replace('/', '.'));
+ sink.link("#" + DoxiaUtils.encodeId(filename));
sink.text(filename);
sink.link_();
sink.tableCell_();
@@ -509,18 +451,13 @@ public class CheckstyleReportGenerator {
sink.tableRow_();
}
- sink.tableRows_();
- sink.table_();
+ endTable();
- sink.section1_();
+ endSection();
}
- private void doDetails(CheckstyleResults results) {
-
- sink.section1();
- sink.sectionTitle1();
- sink.text(bundle.getString("report.checkstyle.details"));
- sink.sectionTitle1_();
+ private void renderDetailsSection() {
+ startSection(getI18nString("details"));
// Sort the files before writing their details to the report
List<String> fileList = new ArrayList<>(results.getFiles().keySet());
@@ -534,57 +471,36 @@ public class CheckstyleReportGenerator {
continue;
}
- sink.section2();
- SinkEventAttributes attrs = new SinkEventAttributeSet();
- attrs.addAttribute(SinkEventAttributes.ID, file.replace('/', '.'));
- sink.sectionTitle(Sink.SECTION_LEVEL_2, attrs);
- sink.text(file);
- sink.sectionTitle_(Sink.SECTION_LEVEL_2);
+ startSection(file);
- sink.table();
- sink.tableRows(null, false);
+ startTable();
- sink.tableRow();
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.column.severity"));
- sink.tableHeaderCell_();
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.rule.category"));
- sink.tableHeaderCell_();
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.rule"));
- sink.tableHeaderCell_();
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.column.message"));
- sink.tableHeaderCell_();
- sink.tableHeaderCell();
- sink.text(bundle.getString("report.checkstyle.column.line"));
- sink.tableHeaderCell_();
- sink.tableRow_();
+ tableHeader(new String[] {
+ getI18nString("column.severity"),
+ getI18nString("rule.category"),
+ getI18nString("rule"),
+ getI18nString("column.message"),
+ getI18nString("column.line")
+ });
- doFileEvents(violations, file);
+ renderFileEvents(violations, file);
- sink.tableRows_();
- sink.table_();
+ endTable();
- sink.section2_();
+ endSection();
}
- sink.section1_();
+ endSection();
}
- private void doFileEvents(List<AuditEvent> eventList, String filename) {
+ private void renderFileEvents(List<AuditEvent> eventList, String filename) {
for (AuditEvent event : eventList) {
SeverityLevel level = event.getSeverityLevel();
- if ((getSeverityLevel() != null) && !(getSeverityLevel() != level)) {
- continue;
- }
-
sink.tableRow();
sink.tableCell();
- iconTool.iconSeverity(level.getName(), IconTool.TEXT_SIMPLE);
+ iconSeverity(level.getName(), TEXT_SIMPLE);
sink.tableCell_();
sink.tableCell();
@@ -641,38 +557,6 @@ public class CheckstyleReportGenerator {
return false;
}
- public SeverityLevel getSeverityLevel() {
- return severityLevel;
- }
-
- public void setSeverityLevel(SeverityLevel severityLevel) {
- this.severityLevel = severityLevel;
- }
-
- public boolean isEnableRulesSummary() {
- return enableRulesSummary;
- }
-
- public void setEnableRulesSummary(boolean enableRulesSummary) {
- this.enableRulesSummary = enableRulesSummary;
- }
-
- public boolean isEnableSeveritySummary() {
- return enableSeveritySummary;
- }
-
- public void setEnableSeveritySummary(boolean enableSeveritySummary) {
- this.enableSeveritySummary = enableSeveritySummary;
- }
-
- public boolean isEnableFilesSummary() {
- return enableFilesSummary;
- }
-
- public void setEnableFilesSummary(boolean enableFilesSummary) {
- this.enableFilesSummary = enableFilesSummary;
- }
-
public String getXrefLocation() {
return xrefLocation;
}
@@ -689,28 +573,38 @@ public class CheckstyleReportGenerator {
this.xrefTestLocation = xrefTestLocation;
}
- public List<File> getTestSourceDirectories() {
- return testSourceDirectories;
- }
-
public void setTestSourceDirectories(List<File> testSourceDirectories) {
this.testSourceDirectories = testSourceDirectories;
}
- public Configuration getCheckstyleConfig() {
- return checkstyleConfig;
- }
-
- public void setCheckstyleConfig(Configuration config) {
- this.checkstyleConfig = config;
- }
-
public void setTreeWalkerNames(List<String> treeWalkerNames) {
this.treeWalkerNames = treeWalkerNames;
}
- public List<String> getTreeWalkerNames() {
- return treeWalkerNames;
+ /**
+ * Render an icon of given level with associated text.
+ * @param level one of <code>INFO</code>, <code>WARNING</code> or <code>ERROR</code> constants
+ * @param textType one of <code>NO_TEXT</code>, <code>TEXT_SIMPLE</code>, <code>TEXT_TITLE</code> or
+ * <code>TEXT_ABBREV</code> constants
+ */
+ private void iconSeverity(String level, int textType) {
+ sink.figureGraphics("images/icon_" + level + "_sml.gif");
+
+ if (textType > NO_TEXT) {
+ sink.nonBreakingSpace();
+ String suffix;
+ switch (textType) {
+ case TEXT_TITLE:
+ suffix = "s";
+ break;
+ case TEXT_ABBREV:
+ suffix = "s.abbrev";
+ break;
+ default:
+ suffix = "";
+ }
+ sink.text(getI18nString(level + suffix));
+ }
}
/**
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/IconTool.java b/src/main/java/org/apache/maven/plugins/checkstyle/IconTool.java
deleted file mode 100644
index 1d65360..0000000
--- a/src/main/java/org/apache/maven/plugins/checkstyle/IconTool.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugins.checkstyle;
-
-import java.util.ResourceBundle;
-
-import org.apache.maven.doxia.sink.Sink;
-
-/**
- * A little tool to deal with info/warning/error icons in Checkstyle reports, with eventual text.
- *
- * @since 2.13
- */
-public class IconTool {
- public static final String INFO = "info";
-
- public static final String WARNING = "warning";
-
- public static final String ERROR = "error";
-
- public static final int NO_TEXT = 0;
- public static final int TEXT_SIMPLE = 1;
- public static final int TEXT_TITLE = 2;
- public static final int TEXT_ABBREV = 3;
-
- private final Sink sink;
-
- private final ResourceBundle bundle;
-
- public IconTool(Sink sink, ResourceBundle bundle) {
- this.sink = sink;
- this.bundle = bundle;
- }
-
- /**
- * Render a simple icon of given level.
- * @param level one of <code>INFO</code>, <code>WARNING</code> or <code>ERROR</code> constants
- */
- public void iconSeverity(String level) {
- sink.figureGraphics("images/icon_" + level + "_sml.gif");
- }
-
- /**
- * Render an icon of given level with associated text.
- * @param level one of <code>INFO</code>, <code>WARNING</code> or <code>ERROR</code> constants
- * @param textType one of <code>NO_TEXT</code>, <code>TEXT_SIMPLE</code>, <code>TEXT_TITLE</code> or
- * <code>TEXT_ABBREV</code> constants
- */
- public void iconSeverity(String level, int textType) {
- sink.figureGraphics("images/icon_" + level + "_sml.gif");
-
- if (textType > 0) {
- sink.nonBreakingSpace();
-
- sink.text(bundle.getString("report.checkstyle." + level + suffix(textType)));
- }
- }
-
- /**
- * Render an info icon.
- */
- public void iconInfo() {
- iconSeverity(INFO);
- }
-
- /**
- * Render an info icon with associated text.
- * @param textType one of <code>NO_TEXT</code>, <code>TEXT_SIMPLE</code>, <code>TEXT_TITLE</code> or
- * <code>TEXT_ABBREV</code> constants
- */
- public void iconInfo(int textType) {
- iconSeverity(INFO, textType);
- }
-
- /**
- * Render a warning icon.
- */
- public void iconWarning() {
- iconSeverity(WARNING);
- }
-
- /**
- * Render a warning icon with associated text.
- * @param textType one of <code>NO_TEXT</code>, <code>TEXT_SIMPLE</code>, <code>TEXT_TITLE</code> or
- * <code>TEXT_ABBREV</code> constants
- */
- public void iconWarning(int textType) {
- iconSeverity(WARNING, textType);
- }
-
- /**
- * Render an error icon.
- */
- public void iconError() {
- iconSeverity(ERROR);
- }
-
- /**
- * Render an error icon with associated text.
- * @param textType one of <code>NO_TEXT</code>, <code>TEXT_SIMPLE</code>, <code>TEXT_TITLE</code> or
- * <code>TEXT_ABBREV</code> constants
- */
- public void iconError(int textType) {
- iconSeverity(ERROR, textType);
- }
-
- private String suffix(int textType) {
- switch (textType) {
- case TEXT_TITLE:
- return "s";
- case TEXT_ABBREV:
- return "s.abbrev";
- default:
- return "";
- }
- }
-}
diff --git a/src/main/resources/checkstyle-report.properties b/src/main/resources/checkstyle-report.properties
index f8ada1b..dbc5483 100644
--- a/src/main/resources/checkstyle-report.properties
+++ b/src/main/resources/checkstyle-report.properties
@@ -41,5 +41,4 @@ report.checkstyle.rule=Rule
report.checkstyle.rules=Rules
report.checkstyle.ruleset=with %s ruleset
report.checkstyle.rule.category=Category
-report.checkstyle.severity_title=Checkstyle errors in severity
report.checkstyle.norule=No rules found
diff --git a/src/main/resources/checkstyle-report_de.properties b/src/main/resources/checkstyle-report_de.properties
index 3cc3d0d..436dbb0 100644
--- a/src/main/resources/checkstyle-report_de.properties
+++ b/src/main/resources/checkstyle-report_de.properties
@@ -40,5 +40,4 @@ report.checkstyle.summary=Zusammenfassung
report.checkstyle.rule=Regel
report.checkstyle.rules=Regeln
report.checkstyle.ruleset=mit %s Regeln
-report.checkstyle.severity_title=Checkstyle-Ergebnisse mit Schweregrad
report.checkstyle.norule=Keine Regeln definiert
diff --git a/src/main/resources/checkstyle-report_fr.properties b/src/main/resources/checkstyle-report_fr.properties
index 131ebb3..d23a202 100644
--- a/src/main/resources/checkstyle-report_fr.properties
+++ b/src/main/resources/checkstyle-report_fr.properties
@@ -41,5 +41,4 @@ report.checkstyle.rule=R
report.checkstyle.rules=R�gles
report.checkstyle.ruleset=avec les r�gles %s
report.checkstyle.rule.category=Cat�gorie
-report.checkstyle.severity_title=Erreurs Checkstyle par s�v�rit�
report.checkstyle.norule=Pas de r�gle trouv�e
diff --git a/src/main/resources/checkstyle-report_pt_BR.properties b/src/main/resources/checkstyle-report_pt_BR.properties
index 2e37e3b..e921862 100644
--- a/src/main/resources/checkstyle-report_pt_BR.properties
+++ b/src/main/resources/checkstyle-report_pt_BR.properties
@@ -40,5 +40,4 @@ report.checkstyle.summary=Sum
report.checkstyle.rule=Regra
report.checkstyle.rules=Regras
report.checkstyle.ruleset=con %s regras
-report.checkstyle.severity_title=Erros do Checkstyle por severidade
report.checkstyle.norule=Nenhuma regra encontrada
diff --git a/src/main/resources/checkstyle-report_sv.properties b/src/main/resources/checkstyle-report_sv.properties
index 9344bae..3b2a2f4 100644
--- a/src/main/resources/checkstyle-report_sv.properties
+++ b/src/main/resources/checkstyle-report_sv.properties
@@ -40,5 +40,4 @@ report.checkstyle.summary=Summering
report.checkstyle.rule=Regel
report.checkstyle.rules=Regler
report.checkstyle.ruleset=med reglerna i %s
-report.checkstyle.severity_title=Checkstyle-fel i sv�righetsgrad
report.checkstyle.norule=Inga regler hittades
diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
index 272c053..e2fe20d 100644
--- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
@@ -170,6 +170,6 @@ public class CheckstyleReportTest extends AbstractCheckstyleTestCase {
}
private static String getHtmlHeader(String s) {
- return ">" + s + "</h2>";
+ return ">" + s + "</h3>";
}
}