Fix the convention check for generated Java methods
Your task
Your Java services follow three conventions. Errors flow through a Result<T> type and never cross a service boundary as exceptions. Every external call goes through the @Resilient wrapper, which adds a timeout and a circuit breaker. Logging is structured. An AI agent's new method broke all three and its tests still passed, so your team turns the conventions into a CI check.
An assistant wrote check_house_conventions(method_lines), the check. It is in the editor. It has a bug. Find it and fix it.
Input and output:
method_lines: the source lines of one method, including any annotation above it.- Return the findings in the order below, each at most once.
Rules the tests check:
no_result_type: no line containsResult<.throws_across_boundary: some line containsthrow newfollowed by a space, or containsthrowswith a space on each side. For this check, add a space to the front of each line first, so a line that starts withthrowsand a space counts.unresilient_external_call: some line containshttpClient., and no line contains@Resilient.unstructured_logging: some line containsSystem.out.orSystem.err..
"Contains" is a plain substring check, case included, so text inside comments counts too.
Examples
check_house_conventions(method_lines: list[str]) -> list[str]Example 1
Input
check_house_conventions([" static UserDto fetchUser(long id) throws IOException {", " var resp = httpClient.get(\"/users/\" + id);", " if (resp.status() != 200) throw new IllegalStateException(\"bad status\");", " System.out.println(\"fetched \" + id);", " return UserDto.from(resp);", " }"])Output
["no_result_type", "throws_across_boundary", "unresilient_external_call", "unstructured_logging"]Example 2
Input
check_house_conventions([" @Resilient(timeout = \"2s\")", " static Result<UserDto> fetchUser(long id) {", " var resp = httpClient.get(\"/users/\" + id);", " if (resp.status() != 200) return Result.failure(\"bad status\");", " log.atInfo().with(\"user_id\", id).log(\"fetched\");", " return Result.success(UserDto.from(resp));", " }"])Output
[]