Skip to content

Commit 205012d

Browse files
committed
review
1 parent 8ccfb0b commit 205012d

5 files changed

Lines changed: 28 additions & 21 deletions

File tree

.github/agents/knowledge/general-rules.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ When a "Knowledge File" is listed, load it from `knowledge/` before reviewing th
1717
| Style | Style guide | Always ||
1818
| Style | Uppercase field names should reflect semantic constants, not simply `static final` | Always ||
1919
| Naming | Getter naming (`get` / `is`) | Always ||
20-
| Style | Prefer `e` for used exceptions, prefer `f` for used exceptions in nested catch clauses when an outer catch already uses `e`, allow `error` for specific `*Error` catch types, prefer `t` for used `Throwable` values, and `ignored` for intentionally unused catch parameters | Catch clauses, `Throwable` params ||
20+
| Style | Prefer `e` for used exceptions, prefer `f` for used exceptions in nested catch clauses when an outer catch already uses `e`, allow `error` for specific `*Error` catch types, prefer `t` for used `Throwable` values, prefer `ignored` for intentionally unused catch parameters, and use `ignore` for nested intentionally unused catch parameters when `ignored` would shadow an outer catch variable | Catch clauses, `Throwable` params ||
2121
| Naming | Module/package naming | New or renamed modules/packages | `module-naming.md` |
2222
| Javaagent | Advice patterns | `@Advice` classes | `javaagent-advice-patterns.md` |
2323
| Javaagent | Module structure patterns | `InstrumentationModule`, `TypeInstrumentation`, `Singletons` | `javaagent-module-patterns.md` |
@@ -107,6 +107,13 @@ Prefer `t` for used `Throwable` values, including `catch (Throwable t)` and
107107

108108
If a catch parameter is intentionally unused, prefer `ignored` over `ignore`.
109109

110+
For nested catch clauses, if `ignored` would shadow an outer catch variable,
111+
prefer `ignore` for the inner intentionally unused catch parameter.
112+
113+
Both `ignored` and `ignore` are recognized by IntelliJ's `CatchMayIgnoreException`
114+
inspection as intentional unused-catch names. In test sources, IntelliJ also
115+
recognizes `expected` and `ok`.
116+
110117
## [Style] Prefer Instance Creation Over Singletons
111118

112119
Stateless implementations of telemetry interfaces — `TextMapGetter`, `TextMapSetter`,

instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static MethodHandle findInheritContextMethodHandle() {
4848
application.io.opentelemetry.instrumentation.annotations.WithSpan.class,
4949
"inheritContext",
5050
MethodType.methodType(boolean.class));
51-
} catch (NoSuchMethodException | IllegalAccessException e) {
51+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
5252
return null;
5353
}
5454
}
@@ -146,7 +146,7 @@ private static boolean inheritContextFromMethod(Method method) {
146146
application.io.opentelemetry.instrumentation.annotations.WithSpan.class);
147147
try {
148148
return (boolean) INHERIT_CONTEXT_METHOD_HANDLE.invoke(annotation);
149-
} catch (Throwable e) {
149+
} catch (Throwable ignored) {
150150
return true;
151151
}
152152
}

instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/MessageAttributesAccessor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ private static MethodHandle findGetAttributes() {
3232
MethodHandles.Lookup lookup = MethodHandles.lookup();
3333
try {
3434
return lookup.findVirtual(Message.class, "getAttributes", methodType(Map.class));
35-
} catch (NoSuchMethodException | IllegalAccessException e) {
35+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
3636
// changed the return type to ConcurrentMap in version 2.1
3737
try {
3838
return lookup.findVirtual(Message.class, "getAttributes", methodType(ConcurrentMap.class));
39-
} catch (NoSuchMethodException | IllegalAccessException f) {
39+
} catch (NoSuchMethodException | IllegalAccessException ignore) {
4040
return null;
4141
}
4242
}
@@ -48,10 +48,10 @@ private static MethodHandle findSetValue() {
4848
try {
4949
// changed the generic bound to NamedValue in version 2.1; earlier than that it's Parameter
5050
setValueReturnType = Class.forName("org.restlet.util.NamedValue");
51-
} catch (ClassNotFoundException e) {
51+
} catch (ClassNotFoundException ignored) {
5252
try {
5353
setValueReturnType = Class.forName("org.restlet.data.Parameter");
54-
} catch (ClassNotFoundException f) {
54+
} catch (ClassNotFoundException ignore) {
5555
return null;
5656
}
5757
}
@@ -60,7 +60,7 @@ private static MethodHandle findSetValue() {
6060
return MethodHandles.lookup()
6161
.findVirtual(
6262
Series.class, "set", methodType(setValueReturnType, String.class, String.class));
63-
} catch (NoSuchMethodException | IllegalAccessException e) {
63+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
6464
return null;
6565
}
6666
}
@@ -70,11 +70,11 @@ private static Class<?> findHeaderClass() {
7070
try {
7171
// restlet 2.3+
7272
return Class.forName("org.restlet.data.Header");
73-
} catch (ClassNotFoundException e) {
73+
} catch (ClassNotFoundException ignored) {
7474
try {
7575
// restlet 2.1-2.2
7676
return Class.forName("org.restlet.engine.header.Header");
77-
} catch (ClassNotFoundException f) {
77+
} catch (ClassNotFoundException ignore) {
7878
// restlet 2.0 does not have Header
7979
return null;
8080
}
@@ -90,7 +90,7 @@ private static MethodHandle findNewSeries() {
9090
// restlet 2.1+ Series has different constructor
9191
return MethodHandles.lookup()
9292
.findConstructor(Series.class, methodType(void.class, Class.class));
93-
} catch (NoSuchMethodException | IllegalAccessException e) {
93+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
9494
return null;
9595
}
9696
}

instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHeadersGetter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ private static MethodHandle findGetAttributes() {
3030
MethodHandles.Lookup lookup = MethodHandles.lookup();
3131
try {
3232
return lookup.findVirtual(Message.class, "getAttributes", MethodType.methodType(Map.class));
33-
} catch (NoSuchMethodException | IllegalAccessException e) {
33+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
3434
// changed the return type to ConcurrentMap in version 2.1
3535
try {
3636
return lookup.findVirtual(
3737
Message.class, "getAttributes", MethodType.methodType(ConcurrentMap.class));
38-
} catch (NoSuchMethodException | IllegalAccessException f) {
38+
} catch (NoSuchMethodException | IllegalAccessException ignore) {
3939
return null;
4040
}
4141
}

instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/ServerCallAccess.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ final class ServerCallAccess {
2323
private static Class<?> findHttpRequestClass() {
2424
try {
2525
return Class.forName("org.restlet.engine.http.HttpRequest");
26-
} catch (ClassNotFoundException e) {
26+
} catch (ClassNotFoundException ignored) {
2727
// moved to another package in version 2.4
2828
try {
2929
return Class.forName("org.restlet.engine.adapter.HttpRequest");
30-
} catch (ClassNotFoundException f) {
30+
} catch (ClassNotFoundException ignore) {
3131
return null;
3232
}
3333
}
@@ -37,11 +37,11 @@ private static Class<?> findHttpRequestClass() {
3737
private static Class<?> findServerCallClass() {
3838
try {
3939
return Class.forName("org.restlet.engine.http.ServerCall");
40-
} catch (ClassNotFoundException e) {
40+
} catch (ClassNotFoundException ignored) {
4141
// moved to another package in version 2.4
4242
try {
4343
return Class.forName("org.restlet.engine.adapter.ServerCall");
44-
} catch (ClassNotFoundException f) {
44+
} catch (ClassNotFoundException ignore) {
4545
return null;
4646
}
4747
}
@@ -55,7 +55,7 @@ private static MethodHandle findGetHttpCall() {
5555
try {
5656
return MethodHandles.publicLookup()
5757
.findVirtual(HTTP_REQUEST_CLASS, "getHttpCall", methodType(SERVER_CALL_CLASS));
58-
} catch (NoSuchMethodException | IllegalAccessException e) {
58+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
5959
return null;
6060
}
6161
}
@@ -68,7 +68,7 @@ private static MethodHandle findGetServerAddress() {
6868
try {
6969
return MethodHandles.publicLookup()
7070
.findVirtual(SERVER_CALL_CLASS, "getServerAddress", methodType(String.class));
71-
} catch (NoSuchMethodException | IllegalAccessException e) {
71+
} catch (NoSuchMethodException | IllegalAccessException ignored) {
7272
return null;
7373
}
7474
}
@@ -84,7 +84,7 @@ static String getServerAddress(Request request) {
8484
}
8585
try {
8686
return (String) GET_SERVER_ADDRESS.invoke(call);
87-
} catch (Throwable e) {
87+
} catch (Throwable ignored) {
8888
return null;
8989
}
9090
}
@@ -97,7 +97,7 @@ private static Object serverCall(Request request) {
9797
if (HTTP_REQUEST_CLASS.isInstance(request)) {
9898
try {
9999
return GET_HTTP_CALL.invoke(request);
100-
} catch (Throwable e) {
100+
} catch (Throwable ignored) {
101101
return null;
102102
}
103103
}

0 commit comments

Comments
 (0)