Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

984 B
Raw Blame
/**
 * Locks that complexity vs cognitive counts stay isolated when sharing one ESLint report.
 * Existence reason: merging tree walks must NOT change either ratchet baseline semantics.
 */
import test from "node:test";
import assert from "node:assert/strict";
import {
  countCognitiveViolations,
  countComplexityViolations,
} from "../../../scripts/check/complexityEslintReport.mjs";

test("countComplexityViolations ignores cognitive-complexity messages", () => {
  const report = [
    {
      messages: [
        { ruleId: "complexity" },
        { ruleId: "max-lines-per-function" },
        { ruleId: "sonarjs/cognitive-complexity" },
        { ruleId: "sonarjs/cognitive-complexity" },
      ],
    },
  ];
  assert.equal(countComplexityViolations(report), 2);
  assert.equal(countCognitiveViolations(report), 2);
});

test("empty report → 0 for both counters", () => {
  assert.equal(countComplexityViolations([]), 0);
  assert.equal(countCognitiveViolations([]), 0);
});