v0.8.2: Quality Rules CLI and Integration - #88
Merged
Conversation
Completes v0.8.1 feature by adding user-facing CLI interface. CLI Commands: - mapper quality list - Show all available quality rules - mapper quality check <package> - Run all enabled rules - mapper quality type-coverage <package> - Check type hint coverage - mapper quality docstring-coverage <package> - Check docstring coverage - mapper quality param-complexity <package> - Check parameter counts All commands support: - --json / --csv output formats - Exit codes for CI/CD (0 = pass, 1 = fail) - Rich console output with colors and file breakdowns Executor: - QualityExecutor class for running rules against Neo4j - execute() - Run single rule with validation - execute_all() - Run all enabled rules - Config loading from mapper.toml - Error handling for missing/disabled rules Tests: - 17 unit tests for executor and CLI commands - Mock-based tests for isolation - Exit code and format validation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated queries to use existing graph structure instead of non-existent properties. Schema Changes: - Get file_path from Module.path via DEFINES relationships - Count parameters via HAS_PARAMETER relationships (not array property) - Defer line numbers to v0.8.4 (GitHub issue #87) Rules Updated: - type_coverage: Query Parameter nodes for has_type_hint - docstring_coverage: Use Module.path for file grouping - param_complexity: Count via HAS_PARAMETER, line set to null Test Results: - All 19 rule unit tests passing - Manual test against datalake/utils package: 3 rules executed - Type coverage: 100% (32/32 functions) - PASS - Docstring coverage: 50% (16/32 functions) - FAIL - Param complexity: 1 violation (8 params) - FAIL - JSON/CSV output validated - Exit codes working correctly Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Renamed tests/unit/quality/test_executor.py to test_quality_executor.py to avoid conflict with tests/unit/query_system/test_executor.py. Python's import system requires unique module names across the test suite. All 290 tests passing with 81% coverage. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ydkadri
reviewed
Apr 20, 2026
| _run_single_rule("param-complexity", package, format_type, json_flag, csv_flag, config_path) | ||
|
|
||
|
|
||
| def _run_single_rule( |
Owner
There was a problem hiding this comment.
Can we create a separate private _quality_helpers module for this. Can we also add an issue to do the same for query helpers
Changed from multiple commands to single 'run' command pattern: - OLD: mapper quality check <package> - OLD: mapper quality type-coverage <package> - NEW: mapper quality run all --package <pkg> - NEW: mapper quality run type-coverage --package <pkg> Changes: - Simplified CLI to 'list' and 'run' commands only - Support 'all' (case insensitive) to run all enabled checks - Extracted execution logic to _quality_helpers.py module - Updated tests to match new API (7 tests, all passing) - Created GitHub issue #89 for query CLI helpers refactoring Benefits: - Consistent with 'mapper query run' API pattern - Cleaner separation of CLI commands vs execution logic - Easier to test (helpers can be unit tested in isolation) - More intuitive --package flag (required option like queries) All 289 unit tests passing, linting clean. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Collaborator
Author
✅ Addressed PR FeedbackComment 1: Match queries API patternChanged CLI interface to match pattern: Before: mapper quality check <package>
mapper quality type-coverage <package>After: mapper quality run all --package <pkg>
mapper quality run type-coverage --package <pkg>Changes:
Comment 2: Extract helpers to separate moduleCreated
Created GitHub issue #89 for query CLI helpers refactoring (same pattern). Testing:
Next: Ready for re-review with new API pattern. |
octo-youcef
marked this pull request as ready for review
May 1, 2026 05:24
Collaborator
Author
✅ Ready for Final ReviewAll feedback addressed, tests passing, documentation updated. Summary
What Changed Since Draft
CI Status
Ready to merge after approval! 🚀 |
ydkadri
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the quality rules feature that shipped incomplete in v0.8.1. Adds CLI commands, executor, and schema compatibility fixes so users can actually run quality checks.
Context: v0.8.1 shipped foundation (models, queries, formatters) but no CLI interface. Users couldn't use the feature. v0.8.2 completes it.
Changes
CLI Commands (Commit 1)
mapper quality list- Show all available rulesmapper quality check <package>- Run all enabled rulesmapper quality type-coverage <package>- Check type hintsmapper quality docstring-coverage <package>- Check docstringsmapper quality param-complexity <package>- Check param counts--json/--csvoutput formatsExecutor (Commit 1)
QualityExecutorclass for running rules against Neo4jexecute(rule_name, package, config)- Single rule with validationexecute_all(package, config)- All enabled rulesSchema Compatibility Fixes (Commit 2)
Problem: Quality rules expected properties that don't exist in current Neo4j schema
Function.file_path,Function.parametersarray,Function.start_lineSolution:
Module.pathvia DEFINES relationshipsTesting (Commit 1, 4)
Commit Structure
What to Review
Critical: Schema Compatibility (Commit 2)
The quality rules now query the graph differently than originally designed:
type_coverage.py (lines 41-64):
Review:
Tradeoff: Line numbers deferred to v0.8.4 (issue #87). Output shows
line: null. Acceptable?Important: CLI Interface (Commit 1)
quality.py (lines 40-128 for
checkcommand):Review:
checkvsrun,type-coveragevstype_coverage)--jsonshorthand vs--format json)Code Quality
executor.py (lines 28-86):
Test coverage:
Documentation
CHANGELOG.md (lines 10-54):
Manual Test Results
Tested against
~/repos/datalake/datalake/utils(32 public functions):JSON output validated, exit codes working correctly.
Before Merge
Related Issues