Todd
Todd

Reputation: 3009

Checkstyle to test XML files?

I'm currently using checkstyle in my POM file. Checkstyle appears to be limited to Java files. Do any modules exist that would allow checking XML files?

Upvotes: 2

Views: 1414

Answers (2)

jdgilday
jdgilday

Reputation: 886

You can use checkstyle with files other than Java. See the google_checks.xml from the Checkstyle repository for an example of using Checkstyle to enforce whitespace on Java, XML, and .properties files.

<property name="fileExtensions" value="java, properties, xml"/>
<!-- Checks for whitespace                               -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter">
    <property name="eachLine" value="true"/>
</module>

Upvotes: 1

barfuin
barfuin

Reputation: 17494

Checkstyle currently supports only Java. Its architecture would allow supporting other languages (like XML), but the team currently does not have the resources or the plans (as of early 2017).

From the Checkstyle GitHub site:

Checkstyle have small team and a huge plans on extending for java language, and it should focus on one language, to be at the top among java analysers. [...]

For next few years i have no plans to support other languages.

So for now, you may want to look at other tools which can analyze XML, such as PMD, SonarQube, etc.

Upvotes: 2

Related Questions