You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat Test.java
public class Test {
/**
* @param some text
*/
public int method(String str)
{
return 1;
}
}
$ java -jar checkstyle-10.12.8-SNAPSHOT-all.jar -j Test.java
|--JAVADOC_TAG -> JAVADOC_TAG [3:5]
| |--PARAM_LITERAL -> @param [3:5]
| |--WS -> [3:11]
| |--PARAMETER_NAME -> some [3:12] // HERE 1
| |--WS -> [3:16]
| `--DESCRIPTION -> DESCRIPTION [3:17]
| |--TEXT -> text [3:17]
| |--NEWLINE -> \n [3:21]
| |--LEADING_ASTERISK -> * [4:0]
| |--TEXT -> / [4:4]
| |--NEWLINE -> \n [4:5]
| |--TEXT -> public void test(String str) [5:0] // HERE 2
| |--NEWLINE -> \n [5:30]
| |--TEXT -> { [6:0]
| |--NEWLINE -> \n [6:3]
| |--TEXT -> } [7:0]
For @param tag if there's a description without the parameter_name it will consider the first word in the Description as the parameter name (look at // HERE 1).
This is not related to the checker itself, it's more related to the parser that builds the AST from the beginning.
As an initial solution, if we are not going to update the parser directly, we may check on the parameters in the method definition ( look at HERE 2).
Example of using a check on such code:
CLI:
$ cat Test.java
public class Test {
/**
* @param some text
*/
public int method(String str)
{
return 1;
}
}
$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<module name="NonEmptyAtclauseDescription"/>
</module>
</module>
$ java -jar checkstyle-10.12.8-SNAPSHOT-all.jar -c config.xml Test.java
Starting audit...
Audit done.
Expected: It should produce a violation since parameter_name is not providerd.
The text was updated successfully, but these errors were encountered:
Based on #14803 (comment)
For
@param
tag if there's a description without theparameter_name
it will consider the first word in the Description as the parameter name (look at// HERE 1
).This is not related to the checker itself, it's more related to the parser that builds the AST from the beginning.
As an initial solution, if we are not going to update the parser directly, we may check on the parameters in the method definition ( look at
HERE 2
).Example of using a check on such code:
CLI:
Expected: It should produce a violation since
parameter_name
is not providerd.The text was updated successfully, but these errors were encountered: