Incorporate patch 566855 from Rob Worth to optionally check that parenthesis

are padded with spaces.

Big thanks to Lars for suggesting that the Pad Option not be a boolean so
somebody could one day submit this patch. :-)
This commit is contained in:
Oliver Burn 2002-08-21 04:39:27 +00:00
parent 9aa8268e47
commit 1fdf65bf01
5 changed files with 50 additions and 4 deletions

View File

@ -324,6 +324,10 @@
<td><span class="code">nospace</span></td>
<td>Do not pad. For example, <span class="code">method(a, b);</span></td>
</tr>
<tr>
<td><span class="code">space</span></td>
<td>Ensure padding. For example, <span class="code">method( a, b );</span></td>
</tr>
</table>

View File

@ -45,6 +45,7 @@
<li class="body">Detect the number of parameters in a declaration exceeding a specified amount (request 582144).</li>
<li class="body">Inspired by patch 580410 from Shinya Ohnuma, now the error message are localised.</li>
<li class="body">Support checking to determine if an unused <span class="code">@throws</span> exception is a subclass of <span class="code">java.lang.Error</span> (request 583719).</li>
<li class="body">Incorporate patch 566855 from Rob Worth to optionally check that parenthesis are padded with spaces.</li>
<li class="body">Incorporate patch 590931 from Vijay Aravamudhan to improve documentation of the build.xml file.</li>
<li class="body">Incorporate patch from Vijay Aravamudhan to enforce requiring @version tag (request 543964).</li>
</ul>

View File

@ -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;

View File

@ -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", ")");
}
}
}

View File

@ -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.",
};