Skip to content

Commit 5fa277b

Browse files
committed
Check for o_O as exception message
Closes gh-189
1 parent 732558c commit 5fa277b

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringCatchCheck.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2019 the original author or authors.
2+
* Copyright 2017-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,6 +60,9 @@ private void checkIdent(DetailAST ast) {
6060
if (text.length() == 1) {
6161
log(ast.getLineNo(), ast.getColumnNo(), "catch.singleLetter");
6262
}
63+
if (text.toLowerCase().equals("o_o")) {
64+
log(ast.getLineNo(), ast.getColumnNo(), "catch.wideEye");
65+
}
6366
}
6467

6568
}

spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/check/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
catch.singleLetter=Single letter catch variable (use "ex" instead).
2+
catch.wideEye=''o_O'' catch variable (use "ex" instead).
23
header.unexpected=Unexpected header.
34
header.mismatch=Line does not match expected header line of ''{0}''.
45
javadoc.badCase=Javadoc element descriptions should not start with an uppercase letter.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
+'o_O' catch variable (use "ex" instead)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2017-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* A invalid catch with o_O as the variable.
19+
*
20+
* @author Phillip Webb
21+
*/
22+
public class CatchOo {
23+
24+
public void test() {
25+
try {
26+
new String("foo");
27+
}
28+
catch (IllegalStateException o_O) {
29+
// Ignore
30+
}
31+
}
32+
33+
}

0 commit comments

Comments
 (0)