find_the_most_critical_design_issue
Analyzes a Java file to pinpoint the single most critical design flaw requiring immediate refactoring, improving maintainability, readability, cohesion, and coupling.
Instructions
Analyze one Java file. Find the most serious design flaw. It must need immediate refactoring. Ignore cosmetic or minor issues. Fix the one problem that will best improve code quality. Code quality means maintainability, readability, loose coupling, and high cohesion. Point out the problem and where it is in the file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/aibolit.ts:30-31 (handler)Main handler: the `aibolit` async function that checks the Aibolit version, validates the file exists, runs 'aibolit check --full', parses warnings by severity, picks the highest-priority issue, and returns a formatted message about the most critical design issue.
export const aibolit = async function(path: string): Promise<string> { check_version(); - src/tools.ts:10-32 (registration)Registration: the tool is registered on the MCP server via `server.tool()` with name 'find_the_most_critical_design_issue', a description prompt (wrapped with to_gpt), a Zod schema expecting a string `path`, and a handler that calls `safe(() => aibolit(path))`.
server.tool( 'find_the_most_critical_design_issue', to_gpt( ` Analyze one Java file. Find the most serious design flaw. It must need immediate refactoring. Ignore cosmetic or minor issues. Fix the one problem that will best improve code quality. Code quality means maintainability, readability, loose coupling, and high cohesion. Point out the problem and where it is in the file. ` ), { path: z.string() }, async ({ path }) => { return ({ content: [{ text: await safe(() => aibolit(path)), type: 'text' }] }); } ); - src/tools.ts:23-23 (schema)Schema: the tool expects a single input parameter `path` of type string, validated with Zod's `z.string()`.
{ path: z.string() }, - src/safe.ts:13-22 (helper)Helper: `safe` wraps the async call to `aibolit` in a try-catch, returning either the result or a formatted error string via to_gpt.
export const safe = async function<T>(f: () => Promise<T>): Promise<T | string> { try { return await f(); } catch (e) { if (e instanceof Error) { return to_gpt(e.message); } return to_gpt(String(e)); } } - src/to_gpt.ts:10-15 (helper)Helper: `to_gpt` normalizes whitespace and punctuation for GPT-friendly formatting, used both for the tool description and the final result.
export const to_gpt = function(txt: string): string { return txt .replace(/\s+/g, ' ') .replace(/ (\?|!|\|,|:)/g, '$1') .trim(); }