fix: remove unreachable else branches in MCP routes

CodeRabbit identified dead code - the else blocks were unreachable
since validation ensures serverId or serverConfig is truthy.
Simplified to ternary expression.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kacper
2025-12-28 15:49:39 +01:00
parent a680f3a9c1
commit ef0a96182a
2 changed files with 8 additions and 24 deletions

View File

@@ -37,18 +37,10 @@ export function createListToolsHandler(mcpTestService: MCPTestService) {
return;
}
let result;
if (body.serverId) {
result = await mcpTestService.testServerById(body.serverId);
} else if (body.serverConfig) {
result = await mcpTestService.testServer(body.serverConfig);
} else {
res.status(400).json({
success: false,
error: 'Invalid request',
});
return;
}
// At this point, we know at least one of serverId or serverConfig is truthy
const result = body.serverId
? await mcpTestService.testServerById(body.serverId)
: await mcpTestService.testServer(body.serverConfig!);
// Return only tool-related information
res.json({

View File

@@ -37,18 +37,10 @@ export function createTestServerHandler(mcpTestService: MCPTestService) {
return;
}
let result;
if (body.serverId) {
result = await mcpTestService.testServerById(body.serverId);
} else if (body.serverConfig) {
result = await mcpTestService.testServer(body.serverConfig);
} else {
res.status(400).json({
success: false,
error: 'Invalid request',
});
return;
}
// At this point, we know at least one of serverId or serverConfig is truthy
const result = body.serverId
? await mcpTestService.testServerById(body.serverId)
: await mcpTestService.testServer(body.serverConfig!);
res.json(result);
} catch (error) {