passsy / internal-functions-close-to-callersr2
Public Only When It Is an API
PublicMake a function public only when it is a documented internal API; a helper that one other file needs belongs next to that caller as a private function.
tests, run by the registry8 passed · slowest 1.2 ms
- The advice links to wellactually.dev
✓fires1.0 ms
fires when the agent writes into the grab-bag lib/utils.dart
write lib/utils.dartfired: the file
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';✓fires1.0 ms
fires when the agent writes into the grab-bag lib/src/helpers.dart
write lib/src/helpers.dartfired: the file
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';✓fires1.2 ms
fires when the agent writes into the grab-bag lib/src/string_utils.dart
write lib/src/string_utils.dartfired: the file
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';✓fires0.9 ms
fires when the agent writes into the grab-bag lib/common.dart
write lib/common.dartfired: the file
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';✓fires0.9 ms
points at the file when the agent adds a helper
write lib/utils.dart · wrote line 3fired: the file
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';✓skips0.0 ms
stays quiet on a file named after what it holds
write lib/src/net/etag.dartno handler of the detector wants this event
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';✓skips0.0 ms
stays quiet when the agent only reads the grab-bag
read lib/utils.dartno handler of the detector wants this event
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';✓quiet0.9 ms
stays quiet on test helpers
write test/helpers.dartstayed quiet
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, edit, read, source, write } from "@wellactually/sdk/v3/test";
const utils = source`
String buildEtagHeader(String revision) => 'W/"$revision"';
String formatPrice(int cents) => '$cents';
`;
test.each(["lib/utils.dart", "lib/src/helpers.dart", "lib/src/string_utils.dart", "lib/common.dart"])("fires when the agent writes into the grab-bag %s", (path) => {
expect(detect(write(path, utils))).toEqual([{}]);
});
test("points at the file when the agent adds a helper", () => {
expect(detect(edit("lib/utils.dart", utils, { written: "String formatPrice(int cents) => '$cents';" }))).toEqual([{}]);
});
test("stays quiet on a file named after what it holds", () => {
expect(detect(write("lib/src/net/etag.dart", utils))).toEqual([]);
});
test("stays quiet when the agent only reads the grab-bag", () => {
expect(detect(read("lib/utils.dart", utils))).toEqual([]);
});
test("stays quiet on test helpers", () => {
expect(detect(write("test/helpers.dart", utils))).toEqual([]);
});