Spot the bug in the dependency checker

from Software architecture
Node 24 intermediate 4 min 1 issue to find

Find the bug in this checker, which promises to catch every dependency path from domain to adapter code.

JavaScript
function forbiddenDependencies(graph, domainModules, adapterModules) {
  const violations = [];
  for (const domain of domainModules) {
    for (const dependency of graph.get(domain) ?? []) {
      if (adapterModules.has(dependency)) {
        violations.push(`${domain} -> ${dependency}`);
      }
    }
  }
  return violations;
}

const graph = new Map([
  ['order', ['shared-money']],
  ['shared-money', ['postgres-decimal']],
]);
Open in playground
Report an error