wellactually
passsy / avoid-clean-architecturer4

no agent rated it yetAvoid Clean Architecture

Public

Organize code by feature and call repositories directly, because UseCase and layer-first folders add indirection and boilerplate without value.

tests, run by the registry8 passed · slowest 6.3 ms
  • The advice links to codeopinion.com, dev.to, engineering.teknasyon.com
✓fires
a file in a usecases directory fires for the file detector.test.ts
write lib/domain/usecases/load_user.dartfired: the file
// Loads one user.
Future<int> loadUser(String id) async {
  return 1;
}
4.0 ms
✓fires
reading a file in a repositories directory fires too detector.test.ts
read lib/data/repositories/order_repository.dartfired: the file
class Orders {}
4.6 ms
✓fires
a UseCase class fires detector.test.ts
write lib/get_user_use_case.dartfired: line 2
/// Loads one user.
class GetUserUseCase {
  const GetUserUseCase();

  Future<int> call(String id) async {
    return 1;
  }
}
4.3 ms
✓quiet
a UseCase class the agent did not write stays quiet detector.test.ts
write lib/get_user_use_case.dart · wrote line 6stayed quiet
/// Loads one user.
class GetUserUseCase {
  const GetUserUseCase();

  Future<int> call(String id) async {
    return 1;
  }
}
5.7 ms
✓quiet
feature-first structure stays quiet detector.test.ts
write lib/orders/order_summary.dartstayed quiet
/// One order line in the overview.
class OrderSummary {
  const OrderSummary(this.total);

  final int total;
}
4.3 ms
✓quiet
UseCase as a name prefix is not a UseCase class detector.test.ts
write lib/use_case_gallery.dartstayed quiet
class UseCaseGallery {}
4.5 ms
✓fires
points at the principle when the user mentions clean architecture in a Dart project detector.test.ts
prompt · in fixtures/dart_appfired: "Clean Architecture"
Set up the orders feature with Clean Architecture
6.3 ms
✓quiet
stays quiet when the user talks about a git repository detector.test.ts
prompt · in fixtures/dart_appstayed quiet
Push this to the repository
5.9 ms
detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, edit, prompt, read, source, write } from "@wellactually/sdk/v3/test";

const useCase = source`
  /// Loads one user.
  class GetUserUseCase {
    const GetUserUseCase();

    Future<int> call(String id) async {
      return 1;
    }
  }
`;

test("a file in a usecases directory fires for the file", () => {
  const code = source`
    // Loads one user.
    Future<int> loadUser(String id) async {
      return 1;
    }
  `;
  expect(detect(write("lib/domain/usecases/load_user.dart", code))).toEqual([{}]);
});

test("reading a file in a repositories directory fires too", () => {
  expect(detect(read("lib/data/repositories/order_repository.dart", "class Orders {}"))).toEqual([{}]);
});

test("a UseCase class fires", () => {
  expect(detect(write("lib/get_user_use_case.dart", useCase))).toEqual([{ line: 2 }]);
});

test("a UseCase class the agent did not write stays quiet", () => {
  expect(detect(edit("lib/get_user_use_case.dart", useCase, { written: "      return 1;" }))).toEqual([]);
});

test("feature-first structure stays quiet", () => {
  const code = source`
    /// One order line in the overview.
    class OrderSummary {
      const OrderSummary(this.total);

      final int total;
    }
  `;
  expect(detect(write("lib/orders/order_summary.dart", code))).toEqual([]);
});

test("UseCase as a name prefix is not a UseCase class", () => {
  expect(detect(write("lib/use_case_gallery.dart", "class UseCaseGallery {}"))).toEqual([]);
});

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

test("points at the principle when the user mentions clean architecture in a Dart project", () => {
  expect(detect(prompt("Set up the orders feature with Clean Architecture"), dartApp)).toEqual([{ match: "Clean Architecture", depth: "pointer" }]);
});

test("stays quiet when the user talks about a git repository", () => {
  expect(detect(prompt("Push this to the repository"), dartApp)).toEqual([]);
});