Reputation: 393
I am new to checkstyle and have spent good enough time on something which i believe should be an easy kill. I want to put a check on the number of lines in my file, which i successfully did. However i am not able to configure checkstyle to ignore empty lines as well as Java Comments before throwing in an error about Size Violations.
Reading their documentation i am of the view that FileLength module doesn't have any property that can be used to ignore comments and whitespaces. Here is the link and the sample code http://checkstyle.sourceforge.net/config_sizes.html
<module name="FileLength">
<property name="max" value="500"/>
The only other exposed property is fileExtensions. Can someone please suggest what is the best way to put a tap on fileSize as well as not to discourage developers from putting in detailed documents?
Upvotes: 1
Views: 1488
Reputation: 17494
This is a good question. First off, there is no way to configure the FileLength check in the way that you need. It simply goes for the number of lines, including everything like a mandatory copyright statement header or whatnot.
So, what I do is this:
Now, by multiplying the values of MethodCount and ExecutableStatementCount, you get a limit like you described, which is a limit on the number of statements per class, instead of a limit on the number of lines.
The actual values will have to undergo some tuning, so be prepared to change them a few times during your project.
Upvotes: 1