Skip to content

Commit d9c463d

Browse files
[checkstyle] OnlyTabIndentationCheck to report filename
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
1 parent 0c6e286 commit d9c463d

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OnlyTabIndentationCheck.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.openhab.tools.analysis.checkstyle.api.AbstractStaticCheck;
1919

2020
import com.puppycrawl.tools.checkstyle.api.FileText;
21+
import com.puppycrawl.tools.checkstyle.api.MessageDispatcher;
2122

2223
/**
2324
* Checks whether whitespace characters are use instead of tabs in xml files
@@ -42,7 +43,11 @@ public void setFileTypes(String[] value) {
4243

4344
@Override
4445
protected void processFiltered(File file, FileText fileText) {
46+
MessageDispatcher dispatcher = getMessageDispatcher();
47+
dispatcher.fireFileStarted(file.getPath());
4548
processTabIndentationCheck(fileText);
49+
fireErrors(file.getAbsolutePath());
50+
dispatcher.fireFileFinished(file.getPath());
4651
}
4752

4853
private void processTabIndentationCheck(FileText fileText) {

sat-plugin/src/main/resources/report/prepare_checkstyle.xslt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,37 @@
3434
<xsl:template match="file">
3535
<xsl:variable name="new_name">
3636
<xsl:choose>
37-
<xsl:when test="contains(@name,'feature.xml')">
37+
<xsl:when test="ends-with(@name,'.xml')">
38+
<!-- this should find the last occurrence of /src/ and construct
39+
a new path from parent folders name, /src/ and remaining path/filename
40+
-->
3841
<xsl:variable name="temp_name" select="translate(@name, '\', '/')" />
39-
<xsl:value-of select="concat('src/', substring-after($temp_name, '/src/'))" />
42+
<xsl:variable name="after_last_src">
43+
<xsl:call-template name="substring-after-last">
44+
<xsl:with-param name="input" select="$temp_name" />
45+
<xsl:with-param name="marker" select="'/src/'" />
46+
</xsl:call-template>
47+
</xsl:variable>
48+
<xsl:variable name="before_last_src" select="substring-before($temp_name, concat('/src/', $after_last_src))" />
49+
<xsl:variable name="parent">
50+
<xsl:choose>
51+
<xsl:when test="string-length($before_last_src) &gt; 0">
52+
<xsl:call-template name="substring-after-last">
53+
<xsl:with-param name="input" select="$before_last_src" />
54+
<xsl:with-param name="marker" select="'/'" />
55+
</xsl:call-template>
56+
</xsl:when>
57+
<xsl:otherwise />
58+
</xsl:choose>
59+
</xsl:variable>
60+
<xsl:choose>
61+
<xsl:when test="string-length($parent) &gt; 0">
62+
<xsl:value-of select="concat($parent, '/src/', $after_last_src)" />
63+
</xsl:when>
64+
<xsl:otherwise>
65+
<xsl:value-of select="concat('src/', $after_last_src)" />
66+
</xsl:otherwise>
67+
</xsl:choose>
4068
</xsl:when>
4169
<xsl:when test="contains(@name,'src')">
4270
<xsl:variable name="temp_name" select="translate(@name, '/', '.')" />

0 commit comments

Comments
 (0)