Skip to content

Commit 9a162e2

Browse files
Johnaverseclaude
andcommitted
Fix SonarQube issues and bump version to 1.1.0
- Fix negated conditions in index.js, mcp-tools.js (S7735) - Fix CSS contrast issues in style.css with solid background colors (S7924) - Reduce cognitive complexity in dataService.js and public/app.js (S3776) - Bump version from 1.0.12 to 1.1.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e32c2de commit 9a162e2

6 files changed

Lines changed: 190 additions & 202 deletions

File tree

dataService.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,24 @@ export function getRelationsById(chainId) {
12891289
* @param {number} maxDepth - Maximum traversal depth (default: 2)
12901290
* @returns {Object|null} Traversal result with nodes and edges, or null if chain not found
12911291
*/
1292+
function collectRelationEdges(chain, chainId, depth, visited, edges, queue) {
1293+
const relations = chain.relations || [];
1294+
for (const rel of relations) {
1295+
if (rel.chainId === undefined) continue;
1296+
1297+
edges.push({
1298+
from: chainId,
1299+
to: rel.chainId,
1300+
kind: rel.kind,
1301+
source: rel.source
1302+
});
1303+
1304+
if (!visited.has(rel.chainId)) {
1305+
queue.push({ chainId: rel.chainId, depth: depth + 1 });
1306+
}
1307+
}
1308+
}
1309+
12921310
export function traverseRelations(startChainId, maxDepth = 2) {
12931311
if (!cachedData.indexed) return null;
12941312

@@ -1315,22 +1333,8 @@ export function traverseRelations(startChainId, maxDepth = 2) {
13151333
depth
13161334
});
13171335

1318-
if (depth >= maxDepth) continue;
1319-
1320-
const relations = chain.relations || [];
1321-
for (const rel of relations) {
1322-
if (rel.chainId === undefined) continue;
1323-
1324-
edges.push({
1325-
from: chainId,
1326-
to: rel.chainId,
1327-
kind: rel.kind,
1328-
source: rel.source
1329-
});
1330-
1331-
if (!visited.has(rel.chainId)) {
1332-
queue.push({ chainId: rel.chainId, depth: depth + 1 });
1333-
}
1336+
if (depth < maxDepth) {
1337+
collectRelationEdges(chain, chainId, depth, visited, edges, queue);
13341338
}
13351339
}
13361340

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export async function buildApp(options = {}) {
189189
return sendError(reply, 400, 'Invalid chain ID');
190190
}
191191

192-
const depth = request.query.depth !== undefined ? parseIntParam(request.query.depth) : 2;
192+
const depth = request.query.depth === undefined ? 2 : parseIntParam(request.query.depth);
193193
if (depth === null || depth < 1 || depth > 5) {
194194
return sendError(reply, 400, 'Invalid depth. Must be between 1 and 5');
195195
}

mcp-tools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function handleTraverseRelations(args) {
352352
return errorResponse('Invalid chain ID');
353353
}
354354

355-
const maxDepth = depth !== undefined ? depth : 2;
355+
const maxDepth = depth ?? 2;
356356
if (typeof maxDepth !== 'number' || maxDepth < 1 || maxDepth > 5) {
357357
return errorResponse('Invalid depth. Must be between 1 and 5');
358358
}
@@ -433,7 +433,7 @@ function handleGetRpcMonitorById(args) {
433433
];
434434
for (const ep of chainResults) {
435435
const block = ep.blockNumber == null ? '' : ` — block #${ep.blockNumber}`;
436-
const latency = ep.latencyMs != null ? ` [${ep.latencyMs}ms]` : '';
436+
const latency = ep.latencyMs == null ? '' : ` [${ep.latencyMs}ms]`;
437437
const client = ep.clientVersion && ep.clientVersion !== 'unavailable' ? ` (${ep.clientVersion})` : '';
438438
lines.push(
439439
`- **${ep.status}** ${ep.url}${block}${latency}${client}`,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chains-api",
3-
"version": "1.0.12",
3+
"version": "1.1.0",
44
"description": "API query service for blockchain chain data from multiple sources",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)