agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
48 lines (40 loc) • 1.35 kB
JavaScript
/**
* @file Analyze frontend-backend integration issues
* @description Single responsibility: Identify mismatches between frontend calls and backend endpoints
*/
const normalizeUrl = require('./normalizeUrl');
function analyzeIntegrationIssues(frontendCalls, backendEndpoints) {
const issues = [];
// Check for missing endpoints
frontendCalls.forEach(call => {
const matchingEndpoint = backendEndpoints.find(endpoint =>
normalizeUrl(endpoint.route) === normalizeUrl(call.url) &&
endpoint.method === call.method
);
if (!matchingEndpoint) {
issues.push({
type: 'missing_endpoint',
severity: 'HIGH',
call,
description: `Frontend calls ${call.method} ${call.url} but no matching backend endpoint found`
});
}
});
// Check for unused endpoints
backendEndpoints.forEach(endpoint => {
const isUsed = frontendCalls.some(call =>
normalizeUrl(endpoint.route) === normalizeUrl(call.url) &&
endpoint.method === call.method
);
if (!isUsed) {
issues.push({
type: 'unused_endpoint',
severity: 'MEDIUM',
endpoint,
description: `Backend endpoint ${endpoint.method} ${endpoint.route} is not called by frontend`
});
}
});
return issues;
}
module.exports = analyzeIntegrationIssues;