Fix the convention check for generated Java methods

Review the AI's codeEasy10 min

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:

  1. no_result_type: no line contains Result<.
  2. throws_across_boundary: some line contains throw new followed by a space, or contains throws with a space on each side. For this check, add a space to the front of each line first, so a line that starts with throws and a space counts.
  3. unresilient_external_call: some line contains httpClient., and no line contains @Resilient.
  4. unstructured_logging: some line contains System.out. or System.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
Inputcheck_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
Inputcheck_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[]