Skip to content

Commit 4b44432

Browse files
committed
ICU-12717 Create ErrorProne reports to find issues
1 parent 594c9b8 commit 4b44432

File tree

12 files changed

+1552
-0
lines changed

12 files changed

+1552
-0
lines changed

.cpyskip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ icu4j/perf-tests/data/collation/ulyss10.txt
104104
icu4j/perf-tests/data/collation/2drvb10.txt
105105
icu4j/perf-tests/data/collation/vfear11a.txt
106106
icu4j/perf-tests/data/collation/nvsbl10.txt
107+
icu4j/tools/build/src/main/resources/com/ibm/icu/dev/tool/errorprone/sorttable.js
107108
#
108109
# docs
109110
#

LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,3 +540,29 @@ publicity pertaining to distribution of the software without specific,
540540
written prior permission. M.I.T. makes no representations about the
541541
suitability of this software for any purpose. It is provided "as is"
542542
without express or implied warranty.
543+
544+
----------------------------------------------------------------------
545+
546+
File: sorttable.js (only for ICU4J)
547+
548+
The MIT Licence, for code from kryogenix.org
549+
550+
Code downloaded from the Browser Experiments section of kryogenix.org is
551+
licenced under the so-called MIT licence. The licence is below.
552+
553+
Copyright (c) 1997-date Stuart Langridge
554+
555+
Permission is hereby granted, free of charge, to any person obtaining a
556+
copy of this software and associated documentation files (the "Software"),
557+
to deal in the Software without restriction, including without limitation
558+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
559+
and/or sell copies of the Software, and to permit persons to whom the
560+
Software is furnished to do so, subject to the following conditions:
561+
562+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
563+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
564+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
565+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
566+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
567+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
568+
SOFTWARE.

icu4j/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
<properties>
5353
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
54+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5455
<maven.compiler.release>11</maven.compiler.release>
5556

5657
<maven-central-repo-url>https://oss.sonatype.org</maven-central-repo-url>
@@ -690,6 +691,7 @@
690691
<showWarnings>true</showWarnings>
691692
<failOnError>false</failOnError>
692693
<fork>true</fork>
694+
<encoding>UTF-8</encoding>
693695
<!-- Use <compilerArg> to pass flags to errorprone. See https://errorprone.info/docs/flags -->
694696
<compilerArgs>
695697
<arg>-XDcompilePolicy=simple</arg>
@@ -702,6 +704,7 @@
702704
<arg>-Xplugin:ErrorProne -XepAllErrorsAsWarnings</arg>
703705
<arg>-Xmaxerrs</arg>
704706
<arg>10000</arg>
707+
<arg>-J-Dfile.encoding=UTF-8</arg>
705708
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
706709
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
707710
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>

icu4j/tools/build/pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,70 @@
1414

1515
<artifactId>tools_build</artifactId>
1616

17+
<properties>
18+
<error_prone.version>2.25.0</error_prone.version>
19+
20+
<!-- Arguments for the errorprone report generation -->
21+
<logFile>/tmp/errorprone.log</logFile>
22+
<srcBaseUrl>https://github.com/unicode-org/icu/blob/main/</srcBaseUrl>
23+
</properties>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>com.google.errorprone</groupId>
28+
<artifactId>error_prone_core</artifactId>
29+
<version>${error_prone.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>commons-cli</groupId>
33+
<artifactId>commons-cli</artifactId>
34+
<version>${commons-cli.version}</version>
35+
</dependency>
36+
</dependencies>
37+
38+
<profiles>
39+
<profile>
40+
<!--
41+
From icu4j:
42+
mvn clean test -ntp -DskipTests -DskipITs -l /tmp/errorprone.log -P errorprone
43+
mvn exec:java -f tools/build/ -P errorprone_report
44+
45+
The links to the source files go to the main GitHub repo (`main` branch).
46+
But when we work locally, or in a fork / branch, the links might point to an incorrect file / line.
47+
You can override the URL by passing -DsrcBaseUrl in the maven command line.
48+
For local files it would be easy to do:
49+
mvn exec:java -f tools/build/ -P errorprone_report -DsrcBaseUrl=$PWD/..
50+
Note: jumping to a certain line does not work on local files.
51+
This is a limitation in how browsers work.
52+
So opening the file in an IDE is probably more practical.
53+
-->
54+
<id>errorprone_report</id>
55+
<build>
56+
<plugins>
57+
<plugin>
58+
<groupId>org.codehaus.mojo</groupId>
59+
<artifactId>exec-maven-plugin</artifactId>
60+
<version>3.5.0</version>
61+
<executions>
62+
<execution>
63+
<goals>
64+
<goal>java</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
<configuration>
69+
<mainClass>com.ibm.icu.dev.tool.errorprone.Main</mainClass>
70+
<arguments>
71+
<argument>--logFile</argument>
72+
<argument>${logFile}</argument>
73+
<argument>--srcBaseUrl</argument>
74+
<argument>${srcBaseUrl}</argument>
75+
</arguments>
76+
</configuration>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
</profile>
81+
</profiles>
82+
1783
</project>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// © 2025 and later: Unicode, Inc. and others.
2+
3+
package com.ibm.icu.dev.tool.errorprone;
4+
5+
import java.util.StringJoiner;
6+
7+
/**
8+
* Error prone issue as parsed from the maven standard output.
9+
*
10+
* <p>Very similar to `com.google.errorprone.BugCheckerInfo`
11+
*/
12+
class ErrorProneEntry {
13+
final String path;
14+
final int line;
15+
16+
@Override
17+
public String toString() {
18+
StringJoiner builder = new StringJoiner("\n ", "ErrorEntry {\n ", "\n}");
19+
builder.add("path:\"" + path + "\"")
20+
.add("line:" + line)
21+
.add("column:" + column)
22+
.add("type:" + type)
23+
.add("message:\"" + message + "\"")
24+
.add("extra:\"" + extra + "\"")
25+
.add("url:\"" + url + "\"");
26+
return builder.toString();
27+
}
28+
29+
final int column;
30+
final String type;
31+
final String message;
32+
String extra;
33+
String url;
34+
String severity;
35+
36+
void addExtra(String toAdd) {
37+
if (extra == null) {
38+
extra = toAdd;
39+
} else {
40+
extra = extra + "\n" + toAdd;
41+
}
42+
}
43+
44+
/** Creates an ErrorEntry object. */
45+
ErrorProneEntry(String path, int line, int column, String type, String message) {
46+
this.path = path;
47+
this.line = line;
48+
this.column = column;
49+
this.type = type;
50+
this.message = message;
51+
this.extra = null;
52+
this.url = null;
53+
this.severity = "???";
54+
}
55+
}

0 commit comments

Comments
 (0)