Oh the pain! Just added column numbers for checks for whitespace. Updating the

unit tests was not fun.
This commit is contained in:
Oliver Burn 2002-04-25 09:04:42 +00:00
parent 552b917ddb
commit 3d8c8ae213
2 changed files with 109 additions and 103 deletions

View File

@ -456,13 +456,15 @@ class Verifier
final int after = aColNo + aText.length() - 1;
if ((before >= 0) && !Character.isWhitespace(line.charAt(before))) {
log(aLineNo, "'" + aText + "' is not preceeded with whitespace.");
log(aLineNo, before + 1,
"'" + aText + "' is not preceeded with whitespace.");
}
if ((after < line.length()) &&
!Character.isWhitespace(line.charAt(after)))
{
log(aLineNo, "'" + aText + "' is not followed by whitespace.");
log(aLineNo, after,
"'" + aText + "' is not followed by whitespace.");
}
}
@ -482,7 +484,7 @@ class Verifier
if ((after >= line.length()) ||
Character.isWhitespace(line.charAt(after)))
{
log(aAST.getLineNo(),
log(aAST.getLineNo(), after,
"'" + aAST.getText() + "' is followed by whitespace.");
}
}
@ -502,6 +504,7 @@ class Verifier
final int before = aAST.getColumnNo() - 1;
if ((before < 0) || Character.isWhitespace(line.charAt(before))) {
log(aAST.getLineNo(),
before,
"'" + aAST.getText() + "' is preceeded with whitespace.");
}
}
@ -544,7 +547,9 @@ class Verifier
{
for (int i = after + 1; i < line.length(); i++) {
if (!Character.isWhitespace(line.charAt(i))) {
log(aAST.getLineNo(), "'.' is followed by whitespace.");
log(aAST.getLineNo(),
after,
"'.' is followed by whitespace.");
break;
}
}
@ -1401,6 +1406,7 @@ class Verifier
&& (aAllow.indexOf(line.charAt(aColNo)) == -1))
{
log(aLineNo,
aColNo,
aConstruct.getText() + " needs to be followed by whitespace.");
}
}

View File

@ -91,28 +91,28 @@ public class CheckerTest
final String filepath = getPath("InputWhitespace.java");
assertNotNull(c);
final String[] expected = {
filepath + ":5: '.' is followed by whitespace.",
filepath + ":5:12: '.' is preceeded with whitespace.",
filepath + ":5:14: '.' is followed by whitespace.",
filepath + ":13: type Javadoc comment is missing an @author tag.",
filepath + ":16: '=' is not preceeded with whitespace.",
filepath + ":16: '=' is not followed by whitespace.",
filepath + ":18: '=' is not followed by whitespace.",
filepath + ":26: '=' is not preceeded with whitespace.",
filepath + ":27: '=' is not preceeded with whitespace.",
filepath + ":27: '=' is not followed by whitespace.",
filepath + ":28: '+=' is not preceeded with whitespace.",
filepath + ":28: '+=' is not followed by whitespace.",
filepath + ":29: '-=' is not followed by whitespace.",
filepath + ":29: '-' is followed by whitespace.",
filepath + ":29: '+' is followed by whitespace.",
filepath + ":30: '++' is preceeded with whitespace.",
filepath + ":30: '--' is preceeded with whitespace.",
filepath + ":31: '++' is followed by whitespace.",
filepath + ":31: '--' is followed by whitespace.",
filepath + ":37: 'synchronized' is not followed by whitespace.",
filepath + ":39: 'try' is not followed by whitespace.",
filepath + ":41: 'catch' is not followed by whitespace.",
filepath + ":58: 'if' is not followed by whitespace.",
filepath + ":16:22: '=' is not preceeded with whitespace.",
filepath + ":16:23: '=' is not followed by whitespace.",
filepath + ":18:24: '=' is not followed by whitespace.",
filepath + ":26:14: '=' is not preceeded with whitespace.",
filepath + ":27:10: '=' is not preceeded with whitespace.",
filepath + ":27:11: '=' is not followed by whitespace.",
filepath + ":28:10: '+=' is not preceeded with whitespace.",
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:21: '+' is followed by 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 + ":39:12: 'try' is not followed by whitespace.",
filepath + ":41:14: 'catch' is not followed by whitespace.",
filepath + ":58:11: 'if' is not followed by whitespace.",
filepath + ":58:12: '(' is followed by whitespace.",
filepath + ":58:36: ')' is preceeded by whitespace.",
filepath + ":59:9: '{' should be on the previous line.",
@ -120,34 +120,34 @@ public class CheckerTest
filepath + ":74:13: '(' is followed by whitespace.",
filepath + ":74:18: ')' is preceeded by whitespace.",
filepath + ":75:9: '{' should be on the previous line.",
filepath + ":76: 'return' is not followed by whitespace.",
filepath + ":76:19: 'return' is not followed by whitespace.",
filepath + ":79:9: '{' should be on the previous line.",
filepath + ":88: cast needs to be followed by whitespace.",
filepath + ":97: '?' is not preceeded with whitespace.",
filepath + ":97: '?' is not followed by whitespace.",
filepath + ":97: ':' is not preceeded with whitespace.",
filepath + ":97: ':' is not followed by whitespace.",
filepath + ":98: '==' is not preceeded with whitespace.",
filepath + ":98: '==' is not followed by whitespace.",
filepath + ":104: '*' is not followed by whitespace.",
filepath + ":104: '*' is not preceeded with whitespace.",
filepath + ":111: '!' is followed by whitespace.",
filepath + ":112: '~' is followed by whitespace.",
filepath + ":119: '%' is not preceeded with whitespace.",
filepath + ":120: '%' is not followed by whitespace.",
filepath + ":121: '%' is not preceeded with whitespace.",
filepath + ":121: '%' is not followed by whitespace.",
filepath + ":123: '/' is not preceeded with whitespace.",
filepath + ":124: '/' is not followed by whitespace.",
filepath + ":125: '/' is not preceeded with whitespace.",
filepath + ":125: '/' is not followed by whitespace.",
filepath + ":129: '.' is followed by whitespace.",
filepath + ":88:21: cast needs to be followed by 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:15: '==' is not preceeded with whitespace.",
filepath + ":98:17: '==' is not followed by whitespace.",
filepath + ":104:20: '*' is not followed by whitespace.",
filepath + ":104:21: '*' is not preceeded with whitespace.",
filepath + ":111:22: '!' is followed by whitespace.",
filepath + ":112:23: '~' is followed by whitespace.",
filepath + ":119:18: '%' is not preceeded with whitespace.",
filepath + ":120:20: '%' is not followed by whitespace.",
filepath + ":121:18: '%' is not preceeded with whitespace.",
filepath + ":121:19: '%' is not followed by whitespace.",
filepath + ":123:18: '/' is not preceeded with whitespace.",
filepath + ":124:20: '/' is not followed by whitespace.",
filepath + ":125:18: '/' is not preceeded with whitespace.",
filepath + ":125:19: '/' is not followed by whitespace.",
filepath + ":129:17: '.' is preceeded with whitespace.",
filepath + ":136: '.' is followed by whitespace.",
filepath + ":129:24: '.' is followed by whitespace.",
filepath + ":136:10: '.' is preceeded with whitespace.",
filepath + ":153: 'assert' is not followed by whitespace.",
filepath + ":156: ':' is not preceeded with whitespace.",
filepath + ":156: ':' is not followed by whitespace.",
filepath + ":136:12: '.' is followed by whitespace.",
filepath + ":153:15: 'assert' is not followed by whitespace.",
filepath + ":156:20: ':' is not preceeded with whitespace.",
filepath + ":156:21: ':' is not followed by whitespace.",
};
verify(c, filepath, expected);
}
@ -161,58 +161,58 @@ public class CheckerTest
final String filepath = getPath("InputWhitespace.java");
assertNotNull(c);
final String[] expected = {
filepath + ":5: '.' is followed by whitespace.",
filepath + ":5:12: '.' is preceeded with whitespace.",
filepath + ":5:14: '.' is followed by whitespace.",
filepath + ":13: type Javadoc comment is missing an @author tag.",
filepath + ":16: '=' is not preceeded with whitespace.",
filepath + ":16: '=' is not followed by whitespace.",
filepath + ":18: '=' is not followed by whitespace.",
filepath + ":26: '=' is not preceeded with whitespace.",
filepath + ":27: '=' is not preceeded with whitespace.",
filepath + ":27: '=' is not followed by whitespace.",
filepath + ":28: '+=' is not preceeded with whitespace.",
filepath + ":28: '+=' is not followed by whitespace.",
filepath + ":29: '-=' is not followed by whitespace.",
filepath + ":29: '-' is followed by whitespace.",
filepath + ":29: '+' is followed by whitespace.",
filepath + ":30: '++' is preceeded with whitespace.",
filepath + ":30: '--' is preceeded with whitespace.",
filepath + ":31: '++' is followed by whitespace.",
filepath + ":31: '--' is followed by whitespace.",
filepath + ":37: 'synchronized' is not followed by whitespace.",
filepath + ":39: 'try' is not followed by whitespace.",
filepath + ":41: 'catch' is not followed by whitespace.",
filepath + ":58: 'if' is not followed by whitespace.",
filepath + ":16:22: '=' is not preceeded with whitespace.",
filepath + ":16:23: '=' is not followed by whitespace.",
filepath + ":18:24: '=' is not followed by whitespace.",
filepath + ":26:14: '=' is not preceeded with whitespace.",
filepath + ":27:10: '=' is not preceeded with whitespace.",
filepath + ":27:11: '=' is not followed by whitespace.",
filepath + ":28:10: '+=' is not preceeded with whitespace.",
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:21: '+' is followed by 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 + ":39:12: 'try' is not followed by whitespace.",
filepath + ":41:14: 'catch' is not followed by 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: 'return' is not followed by whitespace.",
filepath + ":76:19: 'return' is not followed by whitespace.",
filepath + ":79:9: '{' should be on the previous line.",
filepath + ":97: '?' is not preceeded with whitespace.",
filepath + ":97: '?' is not followed by whitespace.",
filepath + ":97: ':' is not preceeded with whitespace.",
filepath + ":97: ':' is not followed by whitespace.",
filepath + ":98: '==' is not preceeded with whitespace.",
filepath + ":98: '==' is not followed by whitespace.",
filepath + ":104: '*' is not followed by whitespace.",
filepath + ":104: '*' is not preceeded with whitespace.",
filepath + ":111: '!' is followed by whitespace.",
filepath + ":112: '~' is followed by whitespace.",
filepath + ":119: '%' is not preceeded with whitespace.",
filepath + ":120: '%' is not followed by whitespace.",
filepath + ":121: '%' is not preceeded with whitespace.",
filepath + ":121: '%' is not followed by whitespace.",
filepath + ":123: '/' is not preceeded with whitespace.",
filepath + ":124: '/' is not followed by whitespace.",
filepath + ":125: '/' is not preceeded with whitespace.",
filepath + ":125: '/' is not followed by whitespace.",
filepath + ":129: '.' is followed by 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:15: '==' is not preceeded with whitespace.",
filepath + ":98:17: '==' is not followed by whitespace.",
filepath + ":104:20: '*' is not followed by whitespace.",
filepath + ":104:21: '*' is not preceeded with whitespace.",
filepath + ":111:22: '!' is followed by whitespace.",
filepath + ":112:23: '~' is followed by whitespace.",
filepath + ":119:18: '%' is not preceeded with whitespace.",
filepath + ":120:20: '%' is not followed by whitespace.",
filepath + ":121:18: '%' is not preceeded with whitespace.",
filepath + ":121:19: '%' is not followed by whitespace.",
filepath + ":123:18: '/' is not preceeded with whitespace.",
filepath + ":124:20: '/' is not followed by whitespace.",
filepath + ":125:18: '/' is not preceeded with whitespace.",
filepath + ":125:19: '/' is not followed by whitespace.",
filepath + ":129:17: '.' is preceeded with whitespace.",
filepath + ":136: '.' is followed by whitespace.",
filepath + ":129:24: '.' is followed by whitespace.",
filepath + ":136:10: '.' is preceeded with whitespace.",
filepath + ":153: 'assert' is not followed by whitespace.",
filepath + ":156: ':' is not preceeded with whitespace.",
filepath + ":156: ':' is not followed by whitespace.",
filepath + ":136:12: '.' is followed by whitespace.",
filepath + ":153:15: 'assert' is not followed by whitespace.",
filepath + ":156:20: ':' is not preceeded with whitespace.",
filepath + ":156:21: ':' is not followed by whitespace.",
};
verify(c, filepath, expected);
}
@ -241,15 +241,15 @@ public class CheckerTest
final String filepath = getPath("InputBraces.java");
final String[] expected = {
filepath + ":29: 'do' construct must use '{}'s.",
filepath + ":41: 'while' is not followed by whitespace.",
filepath + ":41: 'while' construct must use '{}'s.",
filepath + ":41:14: 'while' is not followed by whitespace.",
filepath + ":42: 'while' construct must use '{}'s.",
filepath + ":44: 'while' construct must use '{}'s.",
filepath + ":45: 'if' construct must use '{}'s.",
filepath + ":58: 'for' is not followed by whitespace.",
filepath + ":58: ';' needs to be followed by whitespace.",
filepath + ":58: ';' needs to be followed by whitespace.",
filepath + ":58: 'for' construct must use '{}'s.",
filepath + ":58:12: 'for' is not followed by whitespace.",
filepath + ":58:23: ';' needs to be followed by whitespace.",
filepath + ":58:29: ';' needs to be followed by whitespace.",
filepath + ":59: 'for' construct must use '{}'s.",
filepath + ":61: 'for' construct must use '{}'s.",
filepath + ":63: 'if' construct must use '{}'s.",
@ -272,10 +272,10 @@ public class CheckerTest
final Checker c = createChecker();
final String filepath = getPath("InputBraces.java");
final String[] expected = {
filepath + ":41: 'while' is not followed by whitespace.",
filepath + ":58: 'for' is not followed by whitespace.",
filepath + ":58: ';' needs to be followed by whitespace.",
filepath + ":58: ';' needs to be followed by whitespace.",
filepath + ":41:14: 'while' is not followed by whitespace.",
filepath + ":58:12: 'for' is not followed by whitespace.",
filepath + ":58:23: ';' needs to be followed by whitespace.",
filepath + ":58:29: ';' needs to be followed by whitespace.",
};
verify(c, filepath, expected);
}
@ -382,15 +382,15 @@ public class CheckerTest
filepath + ":30: variable 'badStatic' must match pattern '^s[A-Z][a-zA-Z0-9]*$'.",
filepath + ":35: variable 'badMember' must match pattern '^m[A-Z][a-zA-Z0-9]*$'.",
filepath + ":39: variable 'mNumCreated2' must be private and have accessor methods.",
filepath + ":42: ',' needs to be followed by whitespace.",
filepath + ":42:40: ',' needs to be followed by whitespace.",
filepath + ":49: variable 'sTest1' must be private and have accessor methods.",
filepath + ":51: variable 'sTest3' must be private and have accessor methods.",
filepath + ":53: variable 'sTest2' must be private and have accessor methods.",
filepath + ":56: variable 'mTest1' must be private and have accessor methods.",
filepath + ":58: variable 'mTest2' must be private and have accessor methods.",
filepath + ":71: ',' needs to be followed by whitespace.",
filepath + ":71: parameter 'badFormat1' must match pattern '^a[A-Z][a-zA-Z0-9]*$'.",
filepath + ":71: parameter 'badFormat2' must match pattern '^a[A-Z][a-zA-Z0-9]*$'.",
filepath + ":71:30: ',' needs to be followed by whitespace.",
filepath + ":72: parameter 'badFormat3' must match pattern '^a[A-Z][a-zA-Z0-9]*$'.",
filepath + ":80: method length is 20 lines (max allowed is 19).",
filepath + ":103: constructor length is 10 lines (max allowed is 9).",