Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import path from 'node:path';
import { openReadonlyOrFail } from './db.js';
import { debug } from './logger.js';
import { paginateResult, printNdjson } from './paginate.js';
import { paginateResult } from './paginate.js';
import { LANGUAGE_REGISTRY } from './parser.js';
import { outputResult } from './result-formatter.js';

// ─── Constants ────────────────────────────────────────────────────────

Expand Down Expand Up @@ -382,15 +383,7 @@ export function astQueryData(pattern, customDbPath, opts = {}) {
export function astQuery(pattern, customDbPath, opts = {}) {
const data = astQueryData(pattern, customDbPath, opts);

if (opts.ndjson) {
printNdjson(data, 'results');
return;
}

if (opts.json) {
console.log(JSON.stringify(data, null, 2));
return;
}
if (outputResult(data, 'results', opts)) return;

// Human-readable output
if (data.results.length === 0) {
Expand Down
9 changes: 4 additions & 5 deletions src/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import path from 'node:path';
import { loadConfig } from './config.js';
import { openReadonlyOrFail } from './db.js';
import { RULE_DEFS } from './manifesto.js';
import { explainData, isTestFile, kindIcon } from './queries.js';
import { explainData, kindIcon } from './queries.js';
import { outputResult } from './result-formatter.js';
import { isTestFile } from './test-filter.js';

// ─── Threshold resolution ───────────────────────────────────────────

Expand Down Expand Up @@ -340,10 +342,7 @@ function defaultHealth() {
export function audit(target, customDbPath, opts = {}) {
const data = auditData(target, customDbPath, opts);

if (opts.json) {
console.log(JSON.stringify(data, null, 2));
return;
}
if (outputResult(data, null, opts)) return;

if (data.functions.length === 0) {
console.log(`No ${data.kind === 'file' ? 'file' : 'function/symbol'} matching "${target}"`);
Expand Down
2 changes: 1 addition & 1 deletion src/boundaries.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { debug } from './logger.js';
import { isTestFile } from './queries.js';
import { isTestFile } from './test-filter.js';

// ─── Glob-to-Regex ───────────────────────────────────────────────────

Expand Down
10 changes: 5 additions & 5 deletions src/branch-compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import os from 'node:os';
import path from 'node:path';
import Database from 'better-sqlite3';
import { buildGraph } from './builder.js';
import { isTestFile, kindIcon } from './queries.js';
import { kindIcon } from './queries.js';
import { outputResult } from './result-formatter.js';
import { isTestFile } from './test-filter.js';

// ─── Git Helpers ────────────────────────────────────────────────────────

Expand Down Expand Up @@ -554,10 +556,8 @@ function formatText(data) {
export async function branchCompare(baseRef, targetRef, opts = {}) {
const data = await branchCompareData(baseRef, targetRef, opts);

if (opts.json || opts.format === 'json') {
console.log(JSON.stringify(data, null, 2));
return;
}
if (opts.format === 'json') opts = { ...opts, json: true };
if (outputResult(data, null, opts)) return;

if (opts.format === 'mermaid') {
console.log(branchCompareMermaid(data));
Expand Down
14 changes: 4 additions & 10 deletions src/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import path from 'node:path';
import { COMPLEXITY_RULES } from './complexity.js';
import { openReadonlyOrFail } from './db.js';
import { info } from './logger.js';
import { paginateResult, printNdjson } from './paginate.js';
import { paginateResult } from './paginate.js';
import { LANGUAGE_REGISTRY } from './parser.js';
import { isTestFile } from './queries.js';
import { outputResult } from './result-formatter.js';
import { isTestFile } from './test-filter.js';

// ─── CFG Node Type Rules (extends COMPLEXITY_RULES) ──────────────────────

Expand Down Expand Up @@ -1437,14 +1438,7 @@ function edgeStyle(kind) {
export function cfg(name, customDbPath, opts = {}) {
const data = cfgData(name, customDbPath, opts);

if (opts.json) {
console.log(JSON.stringify(data, null, 2));
return;
}
if (opts.ndjson) {
printNdjson(data.results);
return;
}
if (outputResult(data, 'results', opts)) return;

if (data.warning) {
console.log(`\u26A0 ${data.warning}`);
Expand Down
6 changes: 3 additions & 3 deletions src/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { loadConfig } from './config.js';
import { findCycles } from './cycles.js';
import { findDbPath, openReadonlyOrFail } from './db.js';
import { matchOwners, parseCodeowners } from './owners.js';
import { isTestFile } from './queries.js';
import { outputResult } from './result-formatter.js';
import { isTestFile } from './test-filter.js';

// ─── Diff Parser ──────────────────────────────────────────────────────

Expand Down Expand Up @@ -361,8 +362,7 @@ export function check(customDbPath, opts = {}) {
process.exit(1);
}

if (opts.json) {
console.log(JSON.stringify(data, null, 2));
if (outputResult(data, null, opts)) {
if (!data.passed) process.exit(1);
return;
}
Expand Down
Loading