This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 06a91f8 Show severity as text instead of skin images
06a91f8 is described below
commit 06a91f81166f6695b62d0aa574e79429b8faef29
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Tue Nov 3 01:48:24 2026 +0000
Show severity as text instead of skin images
The report drew each severity with images/icon_*_sml.gif from the site
skin, followed by the severity name.
The name now carries the severity on its own, so a skin without those
images leaves no broken images.
Closes #735
---
.../checkstyle/CheckstyleReportRenderer.java | 51 ++++++++++------------
.../plugins/checkstyle/CheckstyleReportTest.java | 2 +
2 files changed, 24 insertions(+), 29 deletions(-)
diff --git
a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
index f6b3061..1149a2e 100644
---
a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
+++
b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
@@ -42,7 +42,6 @@ import org.codehaus.plexus.i18n.I18N;
* Generate a report based on CheckstyleResults.
*/
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;
@@ -314,7 +313,7 @@ public class CheckstyleReportRenderer extends
AbstractMavenReportRenderer {
// 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 = getConfigProperty(checkerConfig,
parentConfiguration, "severity", "error");
- iconSeverity(severity, TEXT_SIMPLE);
+ severityText(severity, TEXT_SIMPLE);
sink.tableCell_();
sink.tableRow_();
@@ -373,15 +372,15 @@ public class CheckstyleReportRenderer extends
AbstractMavenReportRenderer {
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconSeverity("info", TEXT_TITLE);
+ severityText("info", TEXT_TITLE);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconSeverity("warning", TEXT_TITLE);
+ severityText("warning", TEXT_TITLE);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconSeverity("error", TEXT_TITLE);
+ severityText("error", TEXT_TITLE);
sink.tableHeaderCell_();
sink.tableRow_();
@@ -411,13 +410,13 @@ public class CheckstyleReportRenderer extends
AbstractMavenReportRenderer {
sink.text(getI18nString("file"));
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconSeverity("info", TEXT_ABBREV);
+ severityText("info", TEXT_ABBREV);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconSeverity("warning", TEXT_ABBREV);
+ severityText("warning", TEXT_ABBREV);
sink.tableHeaderCell_();
sink.tableHeaderCell();
- iconSeverity("error", TEXT_ABBREV);
+ severityText("error", TEXT_ABBREV);
sink.tableHeaderCell_();
sink.tableRow_();
@@ -504,7 +503,7 @@ public class CheckstyleReportRenderer extends
AbstractMavenReportRenderer {
sink.tableRow();
sink.tableCell();
- iconSeverity(level.getName(), TEXT_SIMPLE);
+ severityText(level.getName(), TEXT_SIMPLE);
sink.tableCell_();
sink.tableCell();
@@ -566,30 +565,24 @@ public class CheckstyleReportRenderer extends
AbstractMavenReportRenderer {
}
/**
- * Render an icon of given level with associated text.
+ * Render the name of the given severity level as text, without the site
skin's severity images.
*
* @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
+ * @param textType one of <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));
+ private void severityText(String level, int textType) {
+ 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/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
index 4c704c6..1e14ecd 100644
---
a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
+++
b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java
@@ -251,6 +251,8 @@ public class CheckstyleReportTest {
}
String str = new String(Files.readAllBytes(generatedReport.toPath()),
StandardCharsets.UTF_8);
+ // severities are text: the report must not rely on the site skin's
severity images
+ assertFalse(str.contains("images/icon_"), "Report references a site
skin image");
ResourceBundle bundle =
ResourceBundle.getBundle("checkstyle-report",
SiteTool.DEFAULT_LOCALE, getClassLoader());