* @return
*/
int testFile(String name) {
File f = new File(name);
LineNumberReader read = null;
try {
read = new LineNumberReader(new FileReader(f));
int l = 1,
maxline = 0;
boolean longline = false;
while (true) {
String line = read.readLine();
if (line == null) {
break;
}
if (line.length() > MAX_LINELENGTH
&&!line.startsWith("org.hsqldb.test.Profile.")) {
System.out.println("long line in " + name + " at line "
+ l);
}
if (line.startsWith(" ")) {
int spaces = 0;
for (; spaces < line.length(); spaces++) {
if (line.charAt(spaces) != ' ') {
break;
}
}
if (spaces > 3 && testLine(line) &&!longline) {
maxline++;
} else if (isLongline(line)) {
longline = true;
} else {
longline = false;
}
String s = line.substring(spaces);
if (s.startsWith("if(")) {
if (!s.endsWith(" {")) {
System.out.println("if( without { in " + name
+ " at line " + l);
}
} else if (s.startsWith("} else if(")) {
if (!s.endsWith(" {")) {
System.out.println("} else if without { in "
+ name + " at line " + l);
}
} else if (s.startsWith("while(")) {
if (!s.endsWith(" {")) {
System.out.println("while( without { in " + name
+ " at line " + l);
}
} else if (s.startsWith("switch(")) {
if (!s.endsWith(" {")) {
System.out.println("switch( without { in " + name
+ " at line " + l);
}
} else if (s.startsWith("do ")) {
if (!s.endsWith(" {")) {
System.out.println("do without { in " + name
+ " at line " + l);
}
}
}
l++;
}
return maxline;
} catch (Exception e) {
printError(e.getMessage());
}
finally {
if(read != null) {
try {
read.close();
} catch (IOException e1) {
}
}
}