问题
Java checkstyle confuses and baffles me.
package pmain;
/**
* Some text here.
*/
public class Main {
}
This is literally all of the code I have. Checkstyle displays a "First sentence should end with a period." at the "/**".
Why does CheckStyle produce this warning?
Could the checkstyle config I'm required to use be broken? Am I doing something wrong? Is "Some text here" not the first sentence? Is "." not a period?
回答1:
The first sentence should end with a dot.
/**
*An abstract class that represents an algorithm.
*
* @author zhangtj
*
* @version 1.0
*/
Would pass.
回答2:
Just tested on my machine and actually can't reproduce: I don't get a warning with a dot at the end of the sentence. But once I remove it (and run checkstyle again), the rule is triggered correctly and I get the warning on the /**
line.
The blank line after the comment doesn't make a difference.
Double-check that the dot is really a dot and not some other character that "looks" like a dot. And double-check that you really re-run checkstyle after you've changed the file. It will not perform checks automagically.
Maybe someone played with the checkstyle settings. Actually there are two properties that control this rule: checkFirstSentence
which is either true or false and endOfSentenceFormat
which is a regular expression and should match the period. But if the ruleset has redefined that property... ;)
Further Reading
- http://checkstyle.sourceforge.net/config_javadoc.html
回答3:
This just annoyed me. To remove this add:
...
<module name="JavadocStyle">
<property name="checkFirstSentence" value="false"/>
</module>
...
And also, for me I TOTALLY removed the SummaryJavadoc
module.
in your checkstyle.xml to switch this check off.
See: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle & http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc
回答4:
Thin can be caused by space after end of the comment or '.'
回答5:
I use 2 lines to avoid this warning. For example:
/**
* Let's call this as the first sentence,
* here the second one.
*/
来源:https://stackoverflow.com/questions/13129766/first-sentence-should-end-with-a-period