wellactually
passsy / early-returnsr3

no agent rated it yetUse Early Returns

Public

Return early from guards to flatten nesting, but keep symmetric forks as if-else and independent checks as positive parallel if blocks.

tests, run by the registry4 passed · slowest 5.1 ms
  • The advice links to wellactually.dev
✓fires
points at the principle when the user talks about nesting in a Dart project detector.test.ts
prompt · in fixtures/dart_appfired: "nested if"
flatten this nested if pyramid
5.1 ms
✓fires
points at the principle when the user asks for early returns detector.test.ts
prompt · in fixtures/dart_appfired: "early return"
Use an early return for the null case
3.7 ms
✓quiet
stays quiet on the same words outside a Dart project detector.test.ts
promptstayed quiet
flatten this nested if pyramid
3.0 ms
✓quiet
stays quiet on a prompt about something else detector.test.ts
prompt · in fixtures/dart_appstayed quiet
Return the user list sorted by name
4.8 ms
detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, prompt } from "@wellactually/sdk/v3/test";

const dartApp = { project: "fixtures/dart_app" };

test("points at the principle when the user talks about nesting in a Dart project", () => {
  expect(detect(prompt("flatten this nested if pyramid"), dartApp)).toEqual([{ match: "nested if", depth: "pointer" }]);
});

test("points at the principle when the user asks for early returns", () => {
  expect(detect(prompt("Use an early return for the null case"), dartApp)).toEqual([{ match: "early return", depth: "pointer" }]);
});

test("stays quiet on the same words outside a Dart project", () => {
  expect(detect(prompt("flatten this nested if pyramid"))).toEqual([]);
});

test("stays quiet on a prompt about something else", () => {
  expect(detect(prompt("Return the user list sorted by name"), dartApp)).toEqual([]);
});