Skip to content

Commit 2f23a2b

Browse files
Copilotxiang17
andauthored
Add explanatory comments to @SuppressWarnings for ErrorProne 2.44.0 (#4536)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
1 parent 1e306dd commit 2f23a2b

File tree

101 files changed

+355
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+355
-156
lines changed

agent/agent-bootstrap/src/main/java/com/microsoft/applicationinsights/agent/bootstrap/BytecodeUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import javax.annotation.Nullable;
1919

2020
// supporting all properties of event, metric, remote dependency and page view telemetry
21-
@SuppressWarnings("TooManyParameters")
21+
@SuppressWarnings("TooManyParameters") // parameter count justified by method complexity
2222
public class BytecodeUtil {
2323

2424
private static BytecodeUtilDelegate delegate;
@@ -324,7 +324,7 @@ public static void onEnter() {
324324
startNanosHolder.set(System.nanoTime());
325325
}
326326

327-
@SuppressWarnings("SystemOut")
327+
@SuppressWarnings("SystemOut") // legitimate use of System.out for logging/output
328328
public static void onExit() {
329329
Long startNanos = startNanosHolder.get();
330330
if (startNanos == null) {

agent/agent-gc-monitor/gc-monitor-api/src/main/java/com/microsoft/gcmonitor/MemoryManagers.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public enum MemoryManagers {
2727

2828
ZGC(GarbageCollectors.Zgc.class);
2929

30-
@SuppressWarnings("ImmutableEnumChecker")
30+
@SuppressWarnings(
31+
"ImmutableEnumChecker") // mutable enum state is intentional and properly synchronized
3132
private final Class<? extends GarbageCollector>[] managers;
3233

3334
public static MemoryManagers of(MemoryManagement manager) {

agent/agent-gc-monitor/gc-monitor-api/src/main/java/com/microsoft/gcmonitor/memorypools/MemoryPools.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ public Shenandoah(Set<GarbageCollector> managers) {
300300
}
301301
}
302302

303-
@SuppressWarnings({"checkstyle:AbbreviationAsWordInName", "MemberName"})
303+
@SuppressWarnings({
304+
"checkstyle:AbbreviationAsWordInName",
305+
"MemberName"
306+
}) // CGroup is the standard abbreviation for Control Group
304307
public static class ZHeap extends MemoryPool {
305308
public static final String POOL_NAME = "ZHeap";
306309

agent/agent-gc-monitor/gc-monitor-core/src/main/java/com/microsoft/gcmonitor/collectors/GcCollectionSample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public GcCollectionSample(
6363

6464
private static Map<MemoryPool, MemoryUsage> groupMemoryUsageByPoolName(
6565
Object map, MemoryManagement memoryManagement) {
66-
@SuppressWarnings("unchecked")
66+
@SuppressWarnings("unchecked") // safe unchecked cast - type verified by runtime context
6767
Map<List<String>, CompositeData> byName = (Map<List<String>, CompositeData>) map;
6868
Map<MemoryPool, MemoryUsage> byIdentifier = new HashMap<>();
6969
try {

agent/agent-gc-monitor/gc-monitor-tests/src/test/java/com/microsoft/gcmonitortests/GcEventGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void main(String[] args) throws InterruptedException {
2525
new GcEventGenerator().run();
2626
}
2727

28-
@SuppressWarnings("SystemOut")
28+
@SuppressWarnings("SystemOut") // legitimate use of System.out for logging/output
2929
private void run() throws InterruptedException {
3030
System.out.println("Hit return to start");
3131

agent/agent-gc-monitor/gc-monitor-tests/src/test/java/com/microsoft/gcmonitortests/GcProcessRunner.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
import javax.management.remote.JMXServiceURL;
2626

2727
// TODO (trask) revisit Java8ApiChecker suppression
28-
@SuppressWarnings({"Java8ApiChecker", "SystemOut", "CatchAndPrintStackTrace"})
28+
@SuppressWarnings({
29+
"Java8ApiChecker",
30+
"SystemOut",
31+
"CatchAndPrintStackTrace"
32+
}) // JFR APIs require Java 11+, but agent targets Java 8 bytecode
2933
public class GcProcessRunner {
3034
private InputStream errorStream;
3135
private InputStream stdOut;

agent/agent-gc-monitor/gc-monitor-tests/src/test/java/com/microsoft/gcmonitortests/VariousCollectorsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static boolean isPresent(
100100
return events.stream().anyMatch(predicate);
101101
}
102102

103-
@SuppressWarnings({"SystemOut", "unused"})
103+
@SuppressWarnings({"SystemOut", "unused"}) // legitimate use of System.out for logging/output
104104
private static void print(List<GcCollectionEvent> events) {
105105
System.out.println("Obtained: " + events.size());
106106
events.forEach(

agent/agent-profiler/agent-alerting/src/main/java/com/microsoft/applicationinsights/alerting/analysis/pipelines/AlertPipelineMXBean.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
package com.microsoft.applicationinsights.alerting.analysis.pipelines;
55

66
// This class name must end in MXBean (case sensitive)
7-
@SuppressWarnings({"checkstyle:AbbreviationAsWordInName", "IdentifierName"})
7+
@SuppressWarnings({
8+
"checkstyle:AbbreviationAsWordInName",
9+
"IdentifierName"
10+
}) // CGroup is the standard abbreviation for Control Group
811
public interface AlertPipelineMXBean {
912

1013
// Attributes

agent/agent-profiler/agent-diagnostics-jfr/src/main/java/com/microsoft/applicationinsights/diagnostics/jfr/AlertBreachJfrEvent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
import jdk.jfr.Name;
1616
import jdk.jfr.StackTrace;
1717

18-
@SuppressWarnings({"Java8ApiChecker"})
18+
@SuppressWarnings({
19+
"Java8ApiChecker"
20+
}) // JFR APIs require Java 11+, but agent targets Java 8 bytecode
1921
@Name("com.microsoft.applicationinsights.diagnostics.jfr.AlertBreach")
2022
@Label("AlertBreach")
2123
@Category("Diagnostic")

agent/agent-profiler/agent-diagnostics-jfr/src/main/java/com/microsoft/applicationinsights/diagnostics/jfr/CGroupData.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
import jdk.jfr.Period;
1717
import jdk.jfr.StackTrace;
1818

19-
@SuppressWarnings({"Java8ApiChecker", "AbbreviationAsWordInName"})
19+
@SuppressWarnings({
20+
"Java8ApiChecker",
21+
"AbbreviationAsWordInName"
22+
}) // JFR APIs require Java 11+, but agent targets Java 8 bytecode
2023
@Name("com.microsoft.applicationinsights.diagnostics.jfr.CGroupData")
2124
@Label("CGroupData")
2225
@Category("Diagnostic")

0 commit comments

Comments
 (0)