Skip to content

fix: wire --no-tests flag to all query commands (CLI + MCP)#47

Merged
carlos-alm merged 4 commits intomainfrom
fix/no-tests-flag-wiring
Feb 23, 2026
Merged

fix: wire --no-tests flag to all query commands (CLI + MCP)#47
carlos-alm merged 4 commits intomainfrom
fix/no-tests-flag-wiring

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Bug fix: The -T/--no-tests flag was missing from 6 CLI commands (query, map, stats, deps, impact, hotspots) and 4 MCP tools (query_function, file_deps, impact_analysis, module_map). The underlying data functions already supported noTests filtering but it was never wired up.
  • Consistency fix: Standardized all --no-tests help text to 'Exclude test/spec files from results' (was 3 different wordings).
  • Dogfood report: Added DOGFOOD-REPORT-2.1.0.md with full testing results from running codegraph v2.1.0 on itself (Windows x64, native engine).

Test plan

  • All 494 tests pass, 0 failures
  • Lint clean (biome)
  • Verified --no-tests works on all fixed commands:
    • map --no-tests shows only source files
    • deps src/builder.js --no-tests filters test importers (5 → 1)
    • impact src/parser.js --no-tests filters test dependents (30 → 8)
    • stats --no-tests filters file count (92 → 59)
    • query buildGraph --no-tests filters test callers
    • hotspots --no-tests excludes test files from rankings
  • Verified commands without --no-tests still work identically

The -T/--no-tests flag was defined on fn, fn-impact, context, explain,
where, diff-impact, and search but missing from query, map, stats, deps,
impact, and hotspots. The underlying data functions already supported
noTests filtering but the CLI never passed it through.

- Add -T/--no-tests to query, map, stats, deps, impact, hotspots in CLI
- Add noTests support to queryNameData and statsData data functions
- Add no_tests schema + handler passthrough to MCP tools: query_function,
  file_deps, impact_analysis, module_map
- Standardize all --no-tests help text to 'Exclude test/spec files from
  results'
- Add DOGFOOD-REPORT-2.1.0.md with full testing results and suggestions
@claude
Copy link

claude bot commented Feb 23, 2026

Claude finished @carlos-alm's task —— View job


PR Review: fix: wire --no-tests flag to all query commands ⭐⭐⭐☆☆

Todo List:

  • Analyze root cause and approach justification
  • Review all changed files for implementation quality
  • Check for configuration changes and test integrity
  • Verify security and performance considerations
  • Provide comprehensive review feedback with rating

Root Cause Analysis

Problem Being Solved: The --no-tests flag was missing from 6 CLI commands (query, map, stats, deps, impact, hotspots) and 4 MCP tools (query_function, file_deps, impact_analysis, module_map). The underlying data functions already supported noTests filtering but weren't exposed at the CLI/MCP interface level.

Why This Approach: This is a legitimate fix addressing missing feature wiring. The underlying functionality existed but wasn't accessible to users.

Risk Assessment: LOW RISK - Adds missing functionality without changing existing behavior.

Critical Concerns

🔴 BUG: statsData doesn't filter properly

Lines 768-793: The noTests parameter is declared (line 740) but only applied to file counts and hotspots. Node/edge statistics are NOT filtered, meaning stats --no-tests reports incorrect totals.

Expected: All aggregations should filter test files
Actual: Only file listing and hotspots filter test files

🟡 INCONSISTENCY: Missing MCP hotspots support

Line 537-543: The hotspots MCP tool doesn't support no_tests parameter despite CLI having it. Handler calls hotspotsData(dbPath, { metric, level, limit }) without noTests option.

🟡 INCOMPLETE: Test coverage gap

Tests: MCP tests verify schema presence but don't test actual filtering behavior works correctly.

Implementation Quality Review

CLI Changes (src/cli.js:65-467)

  • Correctly adds -T, --no-tests to 6 missing commands
  • Properly passes noTests: !opts.tests to data functions
  • Help text standardized to 'Exclude test/spec files from results'
  • Follows existing patterns consistently

MCP Tool Updates (src/mcp.js:33,45,57,77)

  • Adds no_tests parameter to 4 MCP tools' schemas
  • Handler correctly passes noTests: args.no_tests to data functions

Data Functions (src/queries.js)

  • queryNameData (195-197): ✅ Filters correctly
  • statsData (768,793): 🔴 Partial filtering only

Documentation

  • Comprehensive dogfood report with testing methodology
  • Legitimate addition to track testing results

Security & Performance

  • ✅ No security concerns - simple flag addition
  • ✅ No performance impact - uses existing filtering logic
  • ✅ No configuration files modified

Final Recommendation

  • Rating: ⭐⭐⭐☆☆ (3/5)
  • Action: APPROVE WITH CONDITIONS
  • Reasoning: This addresses a real missing feature and follows correct patterns, but has implementation bugs that should be fixed before merge. The statsData filtering bug affects core functionality accuracy.

Required Fixes:

  1. Fix statsData filtering - Apply noTests filter to node/edge queries, not just file listing
  2. Add no_tests to hotspots MCP tool - Both schema and handler
  3. Add behavioral tests - Verify filtering actually works

Despite the bugs, this is fundamentally sound feature completion work that improves user experience.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Wires the --no-tests flag to 6 CLI commands (query, map, stats, deps, impact, hotspots) and 4 MCP tools (query_function, file_deps, impact_analysis, module_map) that were previously missing this filtering capability. The underlying data functions already supported noTests filtering, but the CLI options and MCP schema definitions weren't exposing it.

  • Standardizes all --no-tests help text to 'Exclude test/spec files from results'
  • Implements filtering in queryNameData and statsData functions using the existing isTestFile helper
  • Updates MCP tool schemas to include no_tests boolean parameter
  • All 494 tests pass with proper test coverage
  • Includes comprehensive dogfood report documenting manual verification

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are purely additive (wiring existing functionality), well-tested (494 tests pass), consistent across all affected commands, properly documented with dogfood verification, and follow established patterns in the codebase
  • No files require special attention

Important Files Changed

Filename Overview
src/cli.js Added --no-tests flag to 6 commands with consistent help text and proper passthrough
src/queries.js Implemented noTests filtering in queryNameData and statsData functions using existing isTestFile helper
src/mcp.js Added no_tests parameter to 4 MCP tool schemas and wired to underlying data functions
tests/unit/mcp.test.js Updated test assertions to expect noTests parameter in function calls

Last reviewed commit: 937b60f

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

The branch name validation only triggered on `git push` and used a
pattern that missed commands prefixed with `cd "..." &&` (common in
worktree sessions). Now validates on both `git push` and `gh pr create`,
and handles the cd prefix pattern for all checks.
@claude
Copy link

claude bot commented Feb 23, 2026

Claude finished @carlos-alm's task —— View job


PR Review: fix: wire --no-tests flag to all query commands ⭐⭐⭐☆☆

Todo List:

  • Phase 1: Root cause analysis - understand what problem this PR solves
  • Phase 2: Configuration change detection - check for risky config changes
  • Phase 3: Test integrity - look for weakened tests or lowered expectations
  • Phase 4: Code quality review - analyze implementation for bugs and issues
  • Provide final rating and recommendation

Root Cause Analysis

Problem Being Solved: The --no-tests flag was missing from 6 CLI commands (query, map, stats, deps, impact, hotspots) and 4 MCP tools (query_function, file_deps, impact_analysis, module_map). The underlying data functions already supported noTests filtering but weren't exposed at the CLI/MCP interface level.

Why This Approach: This is a legitimate bug fix addressing missing feature wiring. The underlying functionality existed in the data layer but wasn't accessible to users through the command interface.

Risk Assessment: LOW RISK - Additive changes that wire existing functionality without modifying core behavior.

Critical Concerns

🔴 BUG: Incomplete statsData filtering

Lines 742-758 (src/queries.js): The noTests parameter filters only file counts and hotspots but NOT the core node/edge statistics:

// Node breakdown by kind
const nodeRows = db.prepare('SELECT kind, COUNT(*) as c FROM nodes GROUP BY kind').all();
// Edge breakdown by kind  
const edgeRows = db.prepare('SELECT kind, COUNT(*) as c FROM edges GROUP BY kind').all();

These queries count ALL nodes/edges including test files, making stats --no-tests report incorrect totals while only filtering the file list and hotspots.

🟡 INCONSISTENCY: Missing MCP hotspots support

Lines 272-291 (src/mcp.js): The hotspots MCP tool schema lacks no_tests parameter despite the CLI having --no-tests flag. Handler calls hotspotsData(dbPath, { metric, level, limit }) without noTests option (lines 537-543).

🟡 INCOMPLETE: Test coverage gap

MCP tests verify schema presence but don't test actual filtering behavior works correctly.

Implementation Quality Review

CLI Changes (src/cli.js:65-467)

  • Correctly adds -T, --no-tests to 6 missing commands
  • Properly passes noTests: !opts.tests to data functions
  • Help text standardized to 'Exclude test/spec files from results'
  • Follows existing patterns consistently

MCP Tool Updates (src/mcp.js:33,45,57,77)

  • Adds no_tests parameter to 4 MCP tools' schemas
  • Handler correctly passes noTests: args.no_tests to data functions

Data Functions (src/queries.js)

  • queryNameData (195-197): ✅ Filters correctly
  • statsData (768,793): 🔴 Partial filtering only

Documentation

  • Comprehensive dogfood report with testing methodology
  • Legitimate addition to track testing results

Security & Performance

  • ✅ No security concerns - simple flag addition
  • ✅ No performance impact - uses existing filtering logic
  • ✅ No configuration files modified

Final Recommendation

  • Rating: ⭐⭐⭐☆☆ (3/5)
  • Action: APPROVE WITH CONDITIONS
  • Reasoning: This addresses a real missing feature and follows correct patterns, but has implementation bugs that should be fixed before merge. The statsData filtering bug affects core functionality accuracy.

Required Fixes:

  1. Fix statsData filtering - Apply noTests filter to node/edge queries, not just file listing
  2. Add no_tests to hotspots MCP tool - Both schema and handler
  3. Add behavioral tests - Verify filtering actually works

Despite the bugs, this is fundamentally sound feature completion work that improves user experience.


@claude
Copy link

claude bot commented Feb 23, 2026

Claude finished @carlos-alm's task —— View job


PR Review: fix: wire --no-tests flag to all query commands ⭐⭐⭐☆☆

Todo List:

  • Phase 1: Root cause analysis - understand what problem this PR solves
  • Phase 2: Configuration change detection - check for risky config changes
  • Phase 3: Test integrity - look for weakened tests or lowered expectations
  • Phase 4: Code quality review - analyze implementation for bugs and issues
  • Provide final rating and recommendation

Root Cause Analysis

Problem Being Solved: The --no-tests flag was missing from 6 CLI commands (query, map, stats, deps, impact, hotspots) and 4 MCP tools (query_function, file_deps, impact_analysis, module_map). The underlying data functions already supported noTests filtering but weren't exposed at the CLI/MCP interface level.

Why This Approach: This is a legitimate bug fix addressing missing feature wiring. The underlying functionality existed in the data layer but wasn't accessible to users through the command interface.

Risk Assessment: LOW RISK - Additive changes that wire existing functionality without modifying core behavior.

Critical Concerns

🔴 BUG: Incomplete statsData filtering

Lines 742-758 (src/queries.js): The noTests parameter filters only file counts and hotspots but NOT the core node/edge statistics:

// Node breakdown by kind
const nodeRows = db.prepare('SELECT kind, COUNT(*) as c FROM nodes GROUP BY kind').all();
// Edge breakdown by kind  
const edgeRows = db.prepare('SELECT kind, COUNT(*) as c FROM edges GROUP BY kind').all();

These queries count ALL nodes/edges including test files, making stats --no-tests report incorrect totals while only filtering the file list and hotspots.

🟡 INCONSISTENCY: Missing MCP hotspots support

Lines 537-543 (src/mcp.js): The hotspots MCP tool handler doesn't pass the noTests parameter despite the CLI having --no-tests flag:

result = hotspotsData(dbPath, {
  metric: args.metric,
  level: args.level,
  limit: args.limit,
  // Missing: noTests: args.no_tests
});

Additionally, the hotspots MCP schema (lines 272-291) lacks the no_tests parameter entirely.

🟡 INCOMPLETE: Test coverage gap

MCP tests verify schema presence but don't test actual filtering behavior works correctly.

Implementation Quality Review

CLI Changes (src/cli.js:65-467)

  • Correctly adds -T, --no-tests to 6 missing commands
  • Properly passes noTests: !opts.tests to data functions
  • Help text standardized to 'Exclude test/spec files from results'
  • Follows existing patterns consistently

MCP Tool Updates (src/mcp.js:33,45,57,77)

  • Adds no_tests parameter to 4 MCP tools' schemas
  • Handler correctly passes noTests: args.no_tests to data functions (except hotspots)

🔴 Data Functions (src/queries.js)

  • queryNameData (195-197): ✅ Filters correctly
  • statsData (742-758): 🔴 Partial filtering only - node/edge counts unfiltered

Test Updates

  • MCP schema tests properly updated
  • No test integrity issues

Final Recommendation

  • Rating: ⭐⭐⭐☆☆ (3/5)
  • Action: APPROVE WITH CONDITIONS
  • Reasoning: This addresses a real missing feature and follows correct patterns, but has implementation bugs that affect core functionality accuracy.

Required Fixes:

  1. Fix statsData filtering - Apply noTests filter to node/edge queries in lines 743-758
  2. Add no_tests to hotspots MCP tool - Both schema (line 272-291) and handler (line 537-543)
  3. Add behavioral tests - Verify filtering actually works end-to-end

Despite the bugs, this is fundamentally sound feature completion work that improves user experience.


- statsData now filters nodes and edges by excluding all nodes belonging
  to test files (previously only file counts and hotspots were filtered)
- Add no_tests schema property and handler passthrough to MCP hotspots tool
- Add 7 integration tests verifying noTests filtering behavior across
  queryNameData, statsData, impactAnalysisData, fileDepsData, moduleMapData
@claude
Copy link

claude bot commented Feb 23, 2026

Claude finished @carlos-alm's task —— View job


Claude finished @unknown's task —— View job


PR Review: fix: wire --no-tests flag to all query commands ⭐⭐⭐⭐☆

Todo List:

  • Phase 1: Root cause analysis - understand what problem this PR solves
  • Phase 2: Configuration change detection - check for risky config changes
  • Phase 3: Test integrity - look for weakened tests or lowered expectations
  • Phase 4: Code quality review - analyze implementation for bugs and issues
  • Provide final rating and recommendation

Root Cause Analysis

Problem Being Solved: The --no-tests flag was missing from 6 CLI commands (query, map, stats, deps, impact, hotspots) and 4 MCP tools (query_function, file_deps, impact_analysis, module_map). The underlying data functions already supported noTests filtering but weren't exposed at the CLI/MCP interface level.

Why This Approach: This is a legitimate bug fix addressing missing feature wiring. The underlying functionality existed in the data layer but wasn't accessible to users through the command interface.

Risk Assessment: LOW RISK - Additive changes that wire existing functionality without modifying core behavior.

Critical Concerns - MAJOR IMPROVEMENTS MADE ✅

FIXED: statsData now filters properly

Lines 738-797 (src/queries.js): The critical bug from previous reviews has been completely fixed! The implementation now properly filters both nodes and edges:

  • Node filtering (lines 763-771): When noTests is true, queries all nodes and filters by test file IDs
  • Edge filtering (lines 781-788): When noTests is true, queries all edges and filters out those with test file source/target IDs
  • Comprehensive test file detection (lines 743-759): Builds complete set of test file IDs including both file nodes and all nodes belonging to test files

FIXED: MCP hotspots now supports no_tests

Lines 272-292 + 538-546 (src/mcp.js): Both the schema and handler have been properly updated:

  • Schema includes no_tests parameter (line 289)
  • Handler passes noTests: args.no_tests to hotspotsData (line 544)

Phase 2: Configuration Change Detection

  • No risky configuration changes - .claude/hooks/guard-git.sh changes are git safety improvements, not rule relaxation
  • No linting/build configuration modified
  • No test timeouts or coverage thresholds lowered

Phase 3: Test Integrity

  • New behavioral tests added - tests/integration/queries.test.js includes actual filtering verification for fileDepsData
  • MCP schema tests updated - Properly validates no_tests parameter presence
  • No weakened assertions or conditional tests
  • No test expectations lowered

Phase 4: Code Quality Review

  • CLI implementation (src/cli.js:65-460): All 7 commands properly wire --no-tests with consistent help text
  • MCP implementation (src/mcp.js): All 5 tools now support no_tests parameter with proper schema and handlers
  • Data layer filtering (src/queries.js): Robust implementation using existing isTestFile helper
  • Test coverage: Both unit tests for schemas and integration tests for actual filtering behavior

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: This PR successfully addresses a real missing feature with high-quality implementation. All critical bugs identified in previous reviews have been fixed. The implementation is comprehensive, well-tested, and follows established patterns. The filtering logic is robust and handles edge cases properly.

Minor notes:

  • The dogfood report addition is legitimate documentation of testing methodology
  • All 494 tests pass as reported
  • No security or performance concerns
  • Excellent consistency across CLI and MCP interfaces

This is solid feature completion work that significantly improves user experience by making test filtering available across all relevant commands.


@carlos-alm carlos-alm merged commit 4e6e20b into main Feb 23, 2026
14 checks passed
@carlos-alm carlos-alm deleted the fix/no-tests-flag-wiring branch February 23, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant