Skip to content

Commit 43a8ff3

Browse files
runningcodeclaude
andcommitted
ref(lint): Tune rules after backtest
Drop publicApi.undocumentedNull, which fired 10 times on October and November PRs without one finding worth a comment. Let unjustifiedBroadCatch accept a commented catch that must also catch LinkageError, since rethrowIfFatal would rethrow it. Make hollowAssertion catch fake clocks that are never advanced. Add two executor rules for missed review comments: hold the SDK executor only as a local, and schedule timeouts on the timer executor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2adc800 commit 43a8ff3

4 files changed

Lines changed: 25 additions & 11 deletions

File tree

‎lint/suites/public-api.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ export default {
1515
"Mark API not meant for customers `@ApiStatus.Internal`, and unstable API `@ApiStatus.Experimental`. " +
1616
"Anything else becomes public API we must keep binary compatible.",
1717
),
18-
undocumentedNull: yesNo(
19-
"Do the new lines add a `@Nullable` parameter or return value to an interface or public method " +
20-
"without documenting what `null` means?",
21-
"A new nullable parameter or return value has no documented meaning for null.",
22-
"Every new nullable parameter or return value documents what null means, or there are none.",
23-
"Document what `null` means here, or make it `@NotNull`.",
24-
),
2518
testOnlyWithoutAnnotation: yesNo(
2619
"Do the new lines add a constructor, method, or setter that is evidently there only for tests " +
2720
"(named or commented as such) without `@TestOnly`?",

‎lint/suites/resources.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ export default {
2121
"The new lines replace no closeable resource, or close or document the old one.",
2222
"Close the resource being replaced, or document that the caller owns it.",
2323
),
24+
heldSdkExecutor: yesNo(
25+
"Do the new lines store the SDK's executor (`getExecutorService()` or `getTimerExecutorService()`) " +
26+
"in a field, or capture it in a long-lived object, instead of reading it from the options each " +
27+
"time it is used?",
28+
"The SDK's executor is held instead of read from the options when used.",
29+
"The new lines don't hold the SDK's executor, or only read it into a local variable before using it.",
30+
"Read the executor from the options each time. The options replace the no-op executor when the SDK " +
31+
"starts, and re-init closes and replaces it, so a held reference can run nothing or a closed executor.",
32+
),
33+
timeoutOnWorkerExecutor: yesNo(
34+
"Do the new lines schedule a timeout or deadline (a callback that fires if something hasn't " +
35+
"happened in time) on `getExecutorService()` rather than `getTimerExecutorService()`?",
36+
"A timeout is scheduled on the worker executor.",
37+
"The new lines schedule no timeout, or schedule it on `getTimerExecutorService()`.",
38+
"Schedule timeouts on `options.getTimerExecutorService()`. On the worker executor they queue behind " +
39+
"cached envelopes and other work, and fire late.",
40+
),
2441
unitlessQuantity: yesNo(
2542
"Do the new lines add a numeric field, parameter, or method for a time or size whose name has no " +
2643
"unit (`Ms`, `Millis`, `Nanos`, `Seconds`, `Bytes`) and whose type does not carry one?",

‎lint/suites/safety.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ export default {
1111
unjustifiedBroadCatch: yesNo(
1212
"Do the new lines add a catch of `Throwable`, `Exception`, `RuntimeException`, or `Error` (in " +
1313
"Java, or Kotlin `catch (e: Exception)` and `runCatching`) that does not both call " +
14-
"`ExceptionUtils.rethrowIfFatal` first and carry a comment saying why the catch must be broad?",
14+
"`ExceptionUtils.rethrowIfFatal` first and carry a comment saying why the catch must be broad? A " +
15+
"catch whose comment says it must also catch `LinkageError` (such as `NoSuchMethodError` from an " +
16+
"old optional dependency) does not need `rethrowIfFatal`, which would rethrow exactly that.",
1517
"A new broad catch is missing the `rethrowIfFatal` call, the comment explaining why it is broad, or both.",
16-
"No new broad catch, or every new broad catch rethrows fatal errors and explains why it is broad.",
18+
"No new broad catch, or every new broad catch rethrows fatal errors and explains why it is broad, or " +
19+
"its comment says it must also catch `LinkageError`.",
1720
"Catch the narrowest type the guarded code can throw. A broad catch is only for boundaries such as " +
1821
"public API entry points, calls into another process, or the body of a task submitted to an " +
1922
"executor; it must call `ExceptionUtils.rethrowIfFatal(t)` first and say in a comment why it is " +

‎lint/suites/tests.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export default {
1616
rules: {
1717
hollowAssertion: yesNo(
1818
"Does a new or changed test have assertions that would still pass if the behavior its name " +
19-
"describes did not happen, for example asserting only that nothing was thrown, or asserting on a " +
20-
"payload without checking the newly added data?",
19+
"describes did not happen, for example asserting only that nothing was thrown, asserting on a " +
20+
"payload without checking the newly added data, or setting up a fake clock, ticker, or scheduler " +
21+
"and never advancing it, so time-dependent behavior is never exercised?",
2122
"A test's assertions don't prove what its name claims.",
2223
"Every new or changed test asserts the behavior it names.",
2324
"Assert the behavior the test names. A test that passes without that behavior protects nothing.",

0 commit comments

Comments
 (0)