diff --git a/docs/engine.html b/docs/engine.html
index 8dc07668c..77aaea7d7 100644
--- a/docs/engine.html
+++ b/docs/engine.html
@@ -324,6 +324,10 @@
nospace |
Do not pad. For example, method(a, b); |
+
+ | space |
+ Ensure padding. For example, method( a, b ); |
+
diff --git a/docs/releasenotes.html b/docs/releasenotes.html
index 303340b80..a78fcbee1 100644
--- a/docs/releasenotes.html
+++ b/docs/releasenotes.html
@@ -45,6 +45,7 @@
Detect the number of parameters in a declaration exceeding a specified amount (request 582144).
Inspired by patch 580410 from Shinya Ohnuma, now the error message are localised.
Support checking to determine if an unused @throws exception is a subclass of java.lang.Error (request 583719).
+ Incorporate patch 566855 from Rob Worth to optionally check that parenthesis are padded with spaces.
Incorporate patch 590931 from Vijay Aravamudhan to improve documentation of the build.xml file.
Incorporate patch from Vijay Aravamudhan to enforce requiring @version tag (request 543964).
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/PadOption.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/PadOption.java
index 2bebbe385..0e4703b97 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/PadOption.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/PadOption.java
@@ -39,6 +39,8 @@ public final class PadOption
public static final PadOption NOSPACE = new PadOption("nospace");
/** represents ignoring the spacing **/
public static final PadOption IGNORE = new PadOption("ignore");
+ /** represents mandatory spacing **/
+ public static final PadOption SPACE = new PadOption("space");
/** the string representation of the option **/
private final String mStrRep;
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java
index d528e2db0..bec87ef1a 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/Verifier.java
@@ -357,7 +357,7 @@ class Verifier
{
mMessages.add(lineNo, "type.missingTag", "@author");
}
- if (mConfig.isRequireVersion()
+ if (mConfig.isRequireVersion()
&& (MATCH_JAVADOC_VERSION.grep(jd).length == 0))
{
mMessages.add(lineNo, "type.missingTag", "@version");
@@ -711,9 +711,17 @@ class Verifier
final String line = mLines[aLineNo - 1];
final int after = aColNo - 1;
if (after < line.length()) {
- if (Character.isWhitespace(line.charAt(after))) {
+ if ((PadOption.NOSPACE == mConfig.getParenPadOption())
+ && (Character.isWhitespace(line.charAt(after))))
+ {
mMessages.add(aLineNo, after, "ws.followed", "(");
}
+ else if ((PadOption.SPACE == mConfig.getParenPadOption())
+ && !Character.isWhitespace(line.charAt(after))
+ && (line.charAt(after) != ')'))
+ {
+ mMessages.add(aLineNo, after, "ws.notFollowed", "(");
+ }
}
}
@@ -733,11 +741,18 @@ class Verifier
final String line = mLines[aLineNo - 1];
final int before = aColNo - 3;
if (before >= 0) {
- if (Character.isWhitespace(line.charAt(before))
+ if ((PadOption.NOSPACE == mConfig.getParenPadOption())
+ && Character.isWhitespace(line.charAt(before))
&& !Utils.whitespaceBefore(before, line))
{
mMessages.add(aLineNo, before, "ws.preceeded", ")");
}
+ else if ((PadOption.SPACE == mConfig.getParenPadOption())
+ && !Character.isWhitespace(line.charAt(before))
+ && (line.charAt(before) != '('))
+ {
+ mMessages.add(aLineNo, before, "ws.notPreceeded", ")");
+ }
}
}
diff --git a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java
index 5acd26619..f16ec5d4a 100644
--- a/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java
+++ b/src/tests/com/puppycrawl/tools/checkstyle/CheckerTest.java
@@ -174,7 +174,7 @@ public class CheckerTest
{
mConfig.setBooleanProperty(Defn.IGNORE_CAST_WHITESPACE_PROP, true);
mConfig.setBooleanProperty(Defn.ALLOW_NO_AUTHOR_PROP, false);
- mConfig.setParenPadOption(PadOption.IGNORE);
+ mConfig.setParenPadOption(PadOption.SPACE);
mConfig.setBlockOptionProperty(Defn.TRY_BLOCK_PROP, BlockOption.IGNORE);
mConfig.setBlockOptionProperty(Defn.CATCH_BLOCK_PROP,
BlockOption.IGNORE);
@@ -195,28 +195,48 @@ public class CheckerTest
filepath + ":28:12: '+=' is not followed by whitespace.",
filepath + ":29:13: '-=' is not followed by whitespace.",
filepath + ":29:14: '-' is followed by whitespace.",
+ filepath + ":29:20: '(' is not followed by whitespace.",
filepath + ":29:21: '+' is followed by whitespace.",
+ filepath + ":29:22: ')' is not preceeded with whitespace.",
filepath + ":30:14: '++' is preceeded with whitespace.",
filepath + ":30:21: '--' is preceeded with whitespace.",
filepath + ":31:15: '++' is followed by whitespace.",
filepath + ":31:22: '--' is followed by whitespace.",
filepath + ":37:21: 'synchronized' is not followed by whitespace.",
+ filepath + ":37:22: '(' is not followed by whitespace.",
+ filepath + ":37:25: ')' is not preceeded with whitespace.",
filepath + ":39:12: 'try' is not followed by whitespace.",
filepath + ":39:12: '{' is not preceeded with whitespace.",
filepath + ":41:14: 'catch' is not followed by whitespace.",
+ filepath + ":41:15: '(' is not followed by whitespace.",
+ filepath + ":41:32: ')' is not preceeded with whitespace.",
filepath + ":41:34: '{' is not preceeded with whitespace.",
filepath + ":58:11: 'if' is not followed by whitespace.",
filepath + ":59:9: '{' should be on the previous line.",
filepath + ":63:9: '{' should be on the previous line.",
filepath + ":75:9: '{' should be on the previous line.",
filepath + ":76:19: 'return' is not followed by whitespace.",
+ filepath + ":76:20: '(' is not followed by whitespace.",
+ filepath + ":76:20: ')' is not preceeded with whitespace.",
filepath + ":79:9: '{' should be on the previous line.",
+ filepath + ":87:21: '(' is not followed by whitespace.",
+ filepath + ":87:26: ')' is not preceeded with whitespace.",
+ filepath + ":88:14: '(' is not followed by whitespace.",
+ filepath + ":88:19: ')' is not preceeded with whitespace.",
+ filepath + ":89:14: '(' is not followed by whitespace.",
+ filepath + ":89:19: ')' is not preceeded with whitespace.",
+ filepath + ":90:14: '(' is not followed by whitespace.",
+ filepath + ":90:19: ')' is not preceeded with whitespace.",
+ filepath + ":97:22: '(' is not followed by whitespace.",
+ filepath + ":97:27: ')' is not preceeded with whitespace.",
filepath + ":97:29: '?' is not preceeded with whitespace.",
filepath + ":97:30: '?' is not followed by whitespace.",
filepath + ":97:34: ':' is not preceeded with whitespace.",
filepath + ":97:35: ':' is not followed by whitespace.",
+ filepath + ":98:14: '(' is not followed by whitespace.",
filepath + ":98:15: '==' is not preceeded with whitespace.",
filepath + ":98:17: '==' is not followed by whitespace.",
+ filepath + ":98:17: ')' is not preceeded with whitespace.",
filepath + ":104:20: '*' is not followed by whitespace.",
filepath + ":104:21: '*' is not preceeded with whitespace.",
filepath + ":111:22: '!' is followed by whitespace.",
@@ -233,7 +253,11 @@ public class CheckerTest
filepath + ":129:24: '.' is followed by whitespace.",
filepath + ":136:10: '.' is preceeded with whitespace.",
filepath + ":136:12: '.' is followed by whitespace.",
+ filepath + ":150:28: '(' is not followed by whitespace.",
+ filepath + ":150:31: ')' is not preceeded with whitespace.",
filepath + ":153:15: 'assert' is not followed by whitespace.",
+ filepath + ":153:16: '(' is not followed by whitespace.",
+ filepath + ":153:19: ')' is not preceeded with whitespace.",
filepath + ":156:20: ':' is not preceeded with whitespace.",
filepath + ":156:21: ':' is not followed by whitespace.",
};