eclipse-cs
eclipse-cs copied to clipboard
Is there an easy way to exclude Maven test directories from checking?
OK, I found it myself ;)
It's under project configuration (right-click on the project -> Properties -> Checkstyle -> Exclude from checking... -> files from packages:
Still think this should be included in FAQ.
And one more thing: normally in the Maven project you have the same package names in main and test source directories - and those directories names are not shown in "Filter packages" view - so one kind of need to guess which ones to check.
ignoring some Checks in maven test folder by checkstyle config - https://github.com/checkstyle/checkstyle/blob/checkstyle-8.17/config/suppressions.xml#L32
Thank you. What do you think, is it worth putting on FAQ?
I don't use suppresstions.xml, does it mean I need to create one?
I think you need to create suppression config.
not sure if it worse to be in FAQ. Suppression is a very big topic.
Before, I don't need to do this setting explicitly.
Today I updated the plugin from version 8.23 to 8.32 and the plugin started scanning src/test/.
Eclipse version: 2020-03 (4.15.0)
@Calixte , do you know anything on this change in behavior ?
No. I don't think we introduced any change that would have this consequence.
If test folders shall be ignored completely, wouldn't it be more useful to configure a BeforeExecutionExclusionFileFilter? My understanding was that this one completely avoids matching files from being processed, while all the suppression filters only throw away found issues after processing. Performance wise that might make a big difference on large code bases, wouldn't it?
Before, I don't need to do this setting explicitly.
Today I updated the plugin from version 8.23 to 8.32 and the plugin started scanning
src/test/.Eclipse version: 2020-03 (4.15.0)
After
- Eclipse Checkstyle version 8.23
src/testnot scanned, everything is ok here

Before
- Eclipse Checkstyle version 8.32
src/testscanned, here seems to be a problem

The Eclipse Checkstyle plugin doesn't differentiate between main sources and test sources (and never did, as far as I know). So it should have been scanning the test sources also in the old version (and that's what it does in all my installations). However, the plugin will definitively only scan source folders which are configured as part of the classpath. Does your old version really contain a source folder (that's the upper rectangle in your second screenshot), and not just a folder (that's the lower rectangle in your second screenshot). If those are two different installations, then you want to compare the .classpath files of the selected project.
One more thing to look at would be "project context menu -> properties -> checkstyle", there you can specify additional criteria for things to include/exclude in the scan.
If those are two different installations, then you want to compare the .classpath files of the selected project.
The .project file is the same in both. No differences.
The only difference between both projects are:
- the version of the checkstyle plugin for Eclipse
- the
checkstyle.xmlfile (because the checkstyle version changes and I needed to make adjustments)
I configured the filter as advised,
<!-- Ignore test sources -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value=".*[\\/]src[\\/]test[\\/].*$"/>
</module>
and indeed using the Checkstyle Gradle plugin the test sources are excluded (when I remove the filter, Gradle flags the test files). However eclipse still flags the files. I tried disabling, then enabling Checkstyle for the project, I tried cleaning the project, the warnings still come back.
Should I file a new ticket as this was originally about something different? Are we misusing it somehow?