-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Description
Check documentation: https://checkstyle.org/config_coding.html#PackageDeclaration
/var/tmp $ javac Test.java
/var/tmp$ cat Test.java
/var/tmp$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="PackageDeclaration"/>
</module>
</module>
/
var/tmp$ java -jar /var/tmp/checkstyle-8.29-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:1: Missing package declaration. [PackageDeclaration]
Audit done.
Checkstyle ends with 1 errors.
problem is detected at https://github.com/checkstyle/checkstyle/pull/8024/files#r404829803
We need to
- remove validation from Check, as we would like to have this Check complete support of Xpath suppression.
- add in our config with RegexpMultiline Check that do this validation
- update xdoc of https://checkstyle.org/config_regexp.html#RegexpMultiline to have it as example.
- remove temporal notes that PackageDeclaration is not completely supported by Xpath that we did at Issue #7758: Update AbstractChecks to log DetailAST - PackageDeclaration #8024
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="RegexpMultiline">
<property name="format" value="^\s*$" />
<property name="matchAcrossLines" value="true" />
<property name="message" value="Empty file is not allowed" />
</module>
</module>
We will lose validation on files where whole content is commented out, see example at #1149 .
To make such validation we need to create some Check that will have AST, if we make Generic Xpath Check (#6481) , it we can do validation without specific Check implementation.