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
➜ src 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="severity" value="error"/><property name="fileExtensions" value="java, properties, xml"/><module name="TreeWalker"><module name="MethodParamPad"><property name="option" value="space"/></module></module></module>
➜ src cat -n Test.java
1 public class Test {
2 public Test () {} // ok, whitespace between id and ()
3
4 public Test (int x) {
5 this (); // ok, 'this' seems to be ignored
6 toString (); // ok, whitespace between id and ()
7 }
8 public Test (int x, int y) {
9 this(x + y); // should be a violation
10 toString(); // violation
11 }
12
13 public Test (int x, int y, int z) {
14 super(); // violation, super constructor call is checked
15 toString(); // violation
16 }
17
18 public Test (int x, int y, int z, int a) {
19 super (); // ok, whitespace between 'super'and ()
20 toString(); // violation
21 }
22 }
➜ src javac Test.java
➜ src java -jar checkstyle-10.12.3-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:10:17: '(' is not preceded with whitespace. [MethodParamPad]
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:14:14: '(' is not preceded with whitespace. [MethodParamPad]
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:15:17: '(' is not preceded with whitespace. [MethodParamPad]
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:20:17: '(' is not preceded with whitespace. [MethodParamPad]
Audit done.
Checkstyle ends with 4 errors.
I would expect Checkstyle to show a violation for the following:
this(x + y);
Example:
➜ src java -jar checkstyle-10.12.3-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:9:13: '(' is not preceded with whitespace. [MethodParamPad]
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:10:17: '(' is not preceded with whitespace. [MethodParamPad]
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:14:14: '(' is not preceded with whitespace. [MethodParamPad]
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:15:17: '(' is not preceded with whitespace. [MethodParamPad]
[ERROR] /home/nick/IdeaProjects/tester/src/Test.java:20:17: '(' is not preceded with whitespace. [MethodParamPad]
Audit done.
Checkstyle ends with 4 errors.
The TLDR; is that if this check validates super constructor invocations, it should also validate explicit constructor invocations.
The text was updated successfully, but these errors were encountered:
I have read check documentation: https://checkstyle.sourceforge.io/checks/whitespace/methodparampad.html#MethodParamPad
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
I would expect Checkstyle to show a violation for the following:
Example:
The TLDR; is that if this check validates super constructor invocations, it should also validate explicit constructor invocations.
The text was updated successfully, but these errors were encountered: