Skip to content

Add quality rules CLI (v0.8.1) - #85

Merged
ydkadri merged 8 commits into
mainfrom
feature/quality-rules
Apr 13, 2026
Merged

Add quality rules CLI (v0.8.1)#85
ydkadri merged 8 commits into
mainfrom
feature/quality-rules

Conversation

@octo-youcef

@octo-youcef octo-youcef commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

🎯 Goal

Implement built-in quality rules for v0.8.1, allowing Tier 1 users to enforce code quality standards without writing Cypher.

📋 Implementation Progress

✅ Phase 1: User Journey (Complete)

  • Created user journey document at docs/user-journeys/10-quality-rules.md
  • Defined 3 quality rules with default thresholds and output formats

✅ Phase 2: Interface Design (Complete)

  • Created interface design document at docs/interface/quality-rules.md
  • Defined CLI commands, configuration schema, data models, Neo4j queries

✅ Phase 3: Implementation Plan (Complete)

  • Implementation plan created in ROADMAP.md with 6-commit structure

✅ Commit 1: Models and Configuration (Complete)

  • Quality rule models (QualityRule ABC, config/result dataclasses using attrs)
  • Configuration loading from mapper.toml with validation
  • 27 unit tests, all passing

✅ Commit 2: Neo4j Queries (Complete - Feedback Addressed)

  • TypeCoverageRule - Query functions with/without type hints
  • DocstringCoverageRule - Query functions with/without docstrings
  • ParamComplexityRule - Query functions exceeding parameter threshold
  • Quality rule registry matching QueryRegistry pattern
  • 25 new unit tests (53 total), all 250 unit tests passing

PR Feedback Addressed:

  • ✅ Consolidated mock_neo4j_connection fixture to tests/unit/conftest.py
  • ✅ Converted dataclasses to attrs (@attrs.define(frozen=True))
  • ✅ Changed Protocol to ABC (matches Query base class pattern)
  • ✅ Made status a calculated property (removes redundant field)
  • ✅ Updated registry to match QueryRegistry pattern (class-based, singleton)
  • ✅ Added all definitions to all modules
  • ✅ Added docstrings to all dataclasses

Milestone Review Complete - All feedback incorporated. Ready to proceed to Commit 3.

⏳ Next Steps

  • Commit 3: Add output formatters (console, JSON, CSV)
  • Commit 4: Add CLI commands → Milestone review
  • Commit 5: Add integration tests → Milestone review
  • Commit 6: Update docs and bump version → Final review

🔗 Related

  • Version: 0.8.1
  • Depends on: v0.8.0 (structured properties)
  • GitHub Issues: None (net-new feature)

📝 Commits

  1. Add user journey for quality rules (v0.8.1)
  2. Add parameter complexity as third quality rule
  3. Add interface design for quality rules (v0.8.1)
  4. Add quality rule models and configuration schema
  5. Add Neo4j queries for each quality rule
  6. Consolidate mock_neo4j_connection fixture
  7. Address PR feedback: attrs, ABC, registry pattern, style guide

@ydkadri ydkadri left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Some comments here. I'd like to discuss them before we proceed.

Comment thread tests/unit/conftest.py
Comment thread src/mapper/quality/models.py Outdated
Comment thread src/mapper/quality/models.py Outdated
Comment thread src/mapper/quality/models.py Outdated
Comment thread src/mapper/quality/registry.py
@octo-youcef

Copy link
Copy Markdown
Collaborator Author

Milestone Review: Commit 3 Complete

Output formatters implemented - Ready for review before proceeding to CLI integration.

What's New (Commit 443cbd5)

Implemented three output formatters for quality rule results:

Console Formatter:

  • Human-readable output with Rich markup (colors, check marks ✓/✗)
  • Single result: detailed breakdown with file-level data and violations
  • Multiple results: summary view with overall pass/fail count

JSON Formatter:

  • Structured JSON arrays for CI/CD integration
  • Different schemas for coverage vs complexity rules
  • jq-compatible indented output

CSV Formatter:

  • Spreadsheet-compatible output for tracking over time
  • Separate schemas for coverage/complexity rules
  • Multiple headers when mixing result types

Testing

  • 23 new tests in test_quality_formatters.py
  • All 76 quality tests passing
  • Full lint compliance (ruff, mypy, isort)

Type Annotations

  • Modernized Optional[X]X | None
  • Modernized Union[X, Y]X | Y

Next Steps (After Review)

  • Commit 4: CLI commands (mapper quality entrypoint)
  • Commit 5: Integration tests + fixture migration
  • Commit 6: Documentation and version bump

Ready for review when convenient. 🚀

@ydkadri ydkadri left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Two inline comments for review

Comment thread docs/contributing/code-architecture.md Outdated

Only expose what is needed outside the package. Keep internal implementation details private.

**IMPORTANT: `__all__` is ONLY for `__init__.py` files**, not regular modules.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Don't need this. It is useful for you but not other contributors. Remove please.

def display_name(self) -> str:
"""Human-readable rule name."""
return "Docstring Coverage"
name: str = "docstring_coverage"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why are quality rule names underscored where query names are hyphened. Please be consistent. Check for other inconsistencies and describe them before making any changes.

octo-youcef added a commit that referenced this pull request Apr 13, 2026
Make quality rule names and fields consistent with query system
patterns to improve codebase uniformity and developer experience.

**Naming Convention Changes:**

1. **Rule names**: Underscores → hyphens (match query naming)
   - `type_coverage` → `type-coverage`
   - `docstring_coverage` → `docstring-coverage`
   - `param_complexity` → `param-complexity`

2. **Field names**: `display_name` → `description` (match Query base class)
   - Updated QualityRule abstract base class
   - Updated all three rule implementations
   - Follows query system pattern with sentence case descriptions

3. **Config keys**: TOML sections use hyphens
   - `[quality.type-coverage]` (not `[quality.type_coverage]`)
   - Consistent with hyphenated rule names

**Implementation Updates:**

- Updated config loader to use hyphenated section names
- Updated console formatters to replace hyphens with spaces (not underscores)
- Updated all tests (76 tests passing)
- Updated all documentation (user journey, interface docs)
- Removed unnecessary `__all__` documentation comment per feedback

**Why this matters:**

- Query names use hyphens: `find-dead-code`, `analyze-call-complexity`
- Quality names now match: `type-coverage`, `docstring-coverage`
- CLI commands already used hyphens: `mapper quality type-coverage`
- Provides consistent developer experience across system

All 273 unit tests passing, linting clean (ruff, mypy, isort).

Closes #85 (comment: consistent naming feedback)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@octo-youcef

Copy link
Copy Markdown
Collaborator Author

PR Feedback Addressed (Commit 0217c35)

Both inline comments have been resolved:

1. Removed unnecessary documentation comment ✓

File:
Action: Removed the comment as requested

2. Made naming consistent with query system ✓

File: (and others)

Changes made:

  • Rule names: Underscores → hyphens to match queries

    • type_coveragetype-coverage
    • docstring_coveragedocstring-coverage
    • param_complexityparam-complexity
  • Field names: display_namedescription to match Query base class

    • Updated abstract property in QualityRule
    • Updated all three rule implementations
  • Config keys: TOML sections now use hyphens

    • [quality.type-coverage] (not [quality.type_coverage])

Why: Query system uses hyphens (find-dead-code, analyze-call-complexity), so quality rules now match for consistency across the codebase.


Testing: All 273 unit tests passing, linting clean (ruff, mypy, isort).

Ready for final review! 🚀

@octo-youcef
octo-youcef marked this pull request as ready for review April 13, 2026 00:43
@octo-youcef

Copy link
Copy Markdown
Collaborator Author

✅ Ready for Final Review

All feedback addressed - PR marked ready for final review.

Summary of Commit 3 (Output Formatters):

  • Console, JSON, and CSV formatters implemented
  • Naming consistency with query system
  • 76 quality tests + 273 total unit tests passing
  • Full lint compliance (ruff, mypy, isort)
  • All documentation updated

Branch: feature/quality-rules
Commits: 3 new commits since last review

  • 443cbd5: Add output formatters
  • 682fa4d: Apply ruff formatting
  • 0217c35: Address PR feedback (naming consistency)

Next steps after merge: Commit 4 (CLI integration) 🎯

octo-youcef and others added 5 commits April 13, 2026 17:33
Phase 1: Align on Approach

Documents the user workflow for running quality rule checks:
- Type coverage enforcement
- Docstring coverage enforcement
- Pass/fail semantics vs exploratory queries
- CI/CD integration with exit codes
- JSON/CSV output formats with jq parsing examples

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Add parameter complexity as third quality rule

- Max 5 parameters per function (configurable)
- Violations show function name, line number, and parameter count
- Updated JSON/CSV output examples
- Updated default thresholds in troubleshooting

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Define CLI commands, configuration schema, output formats, and quality rule specifications:
- CLI: mapper quality {check,type-coverage,docstring-coverage,param-complexity}
- Config: mapper.toml [quality.*] sections with enable/threshold/exclude options
- Output: console (human-readable), JSON (CI/CD), CSV (tracking)
- Models: QualityRule protocol, config dataclasses, result models
- Queries: Neo4j Cypher queries for each rule using structured properties
- Formatters: console, JSON, CSV output formatters

Phase 2 complete - interface design ready for implementation planning.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Foundation for quality rule system with three built-in rules:
- Type coverage (80% default threshold)
- Docstring coverage (90% default threshold)
- Parameter complexity (5 parameters max default)

Models:
- QualityRule protocol for extensibility
- Config dataclasses (QualityConfig, TypeCoverageConfig, etc.)
- Result dataclasses (CoverageQualityResult, ComplexityQualityResult)
- FileResult, OverallResult, ViolationDetail, FileViolations

Configuration:
- load_quality_config() loads from mapper.toml [quality.*] sections
- Validation: percentages 0-100, max_parameters > 0
- Default values when config missing
- Exclude pattern support for all rules

Tests:
- 14 tests for configuration loading (defaults, validation, partial config)
- 13 tests for model creation
- All 224 unit tests passing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement three quality rules with Cypher queries:

Type Coverage Rule:
- Query functions with/without type hints on parameters
- Aggregate by file with percentage calculation
- Apply exclude patterns (test_*, __init__, etc.)
- Return CoverageQualityResult

Docstring Coverage Rule:
- Query functions with/without docstrings
- Aggregate by file with percentage calculation
- Apply exclude patterns (__str__, __repr__, etc.)
- Return CoverageQualityResult

Parameter Complexity Rule:
- Query functions exceeding parameter threshold
- Group violations by file with line numbers
- Apply exclude patterns (__init__, etc.)
- Return ComplexityQualityResult with violation details

Registry:
- get_rule(name) - Get rule by name
- get_all_rules() - Get all registered rules
- get_rule_names() - Get rule names

Tests:
- 25 new unit tests (3 rules + registry)
- Mock Neo4j connection for query testing
- Test pass/fail status determination
- Test exclude pattern application
- All 249 unit tests passing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Address PR feedback: attrs, ABC, registry pattern, style guide

Convert quality system to match project patterns:

1. Use attrs instead of dataclasses
   - All models use @attrs.define(frozen=True)
   - Consistent with query system (query.Query, query.QueryResult)

2. Change Protocol to ABC
   - QualityRule now inherits from ABC with abstract methods
   - Matches Query base class pattern
   - Concrete rules use @attrs.define(frozen=True)

3. Make status a calculated property
   - CoverageQualityResult.status: actual >= threshold
   - ComplexityQualityResult.status: total_violations == 0
   - Removes redundant stored field

4. Match QueryRegistry pattern
   - Class-based registry with __init__
   - Singleton pattern with get_registry()
   - BUILTIN_RULES list (like BUILTIN_QUERIES)
   - Consistent method names (get, list_all, get_rule_names)

5. Add __all__ definitions (style guide compliance)
   - models.py: 11 public items
   - config.py: load_quality_config
   - registry.py: QualityRuleRegistry, get_registry
   - rules/*.py: Rule classes
   - __init__.py: config, models, registry modules

6. Add docstrings to all dataclasses (style guide compliance)
   - All attrs classes have module docstring
   - Attributes documented in class docstring

Tests updated:
- Registry tests use get_registry() method
- Result tests don't pass status (now a property)
- All 250 unit tests passing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Consolidate mock_neo4j_connection fixture

Move duplicate fixture to tests/unit/conftest.py:
- Removed from tests/unit/quality/conftest.py
- Removed from tests/unit/query_system/test_executor.py
- Now shared across all unit tests

Note: Integration test fixture in test_init_workflow.py is different
(patches Neo4jConnection class) so left unchanged.

All 57 unit tests passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement three formatters for quality rule results to support different
output contexts:

**Console Formatter**:
- Human-readable output with Rich markup (colors, symbols)
- Check marks (✓/✗) for pass/fail status
- Single result: detailed breakdown with file-level data and violations
- Multiple results: summary view with overall pass/fail count

**JSON Formatter**:
- Structured JSON arrays for CI/CD integration
- Different schemas for coverage vs complexity rules
- Indented output (jq-compatible)

**CSV Formatter**:
- Spreadsheet-compatible output for tracking over time
- Coverage schema: rule,file_path,total_functions,compliant_functions,compliance_percentage,status
- Complexity schema: rule,file_path,function_name,line_number,parameter_count,status
- Separate headers for mixed result types

**Pattern**:
- OutputFormat(str, Enum) for type-safe format selection
- FormatsQualityResults protocol defining formatter interface
- get_formatter() factory function with match/case

**Type Annotation Updates**:
- Modernize Optional[X] → X | None throughout quality package
- Modernize Union[X, Y] → X | Y for Python 3.10+ syntax

**Tests**: 23 new tests in test_quality_formatters.py
- All three formatters with both result types
- Single vs multiple result formatting
- Edge cases (empty results, no violations)
- Enum string compatibility

All 76 quality tests passing, linting clean (ruff, mypy, isort).

Part of v0.8.1 - Built-in Quality Rules (Commit 3/6).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Clarify __all__ is only for __init__.py files

Remove __all__ from regular modules (only keep in __init__.py):
- src/mapper/quality/models.py
- src/mapper/quality/config.py
- src/mapper/quality/registry.py
- src/mapper/quality/rules/type_coverage.py
- src/mapper/quality/rules/docstring_coverage.py
- src/mapper/quality/rules/param_complexity.py

Keep __all__ in:
- src/mapper/quality/__init__.py (package entry point)
- src/mapper/quality/rules/__init__.py (package entry point)

Update code-architecture.md:
- Add explicit note: __all__ is ONLY for __init__.py files
- Show example of regular module WITHOUT __all__
- Clarify that regular modules use underscore prefixes for private items

All 53 quality tests passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Apply ruff formatting to test files

Auto-formatting applied to test_param_complexity_rule.py and
test_type_coverage_rule.py for line length compliance.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Address PR feedback: consistent naming and field conventions

Make quality rule names and fields consistent with query system
patterns to improve codebase uniformity and developer experience.

**Naming Convention Changes:**

1. **Rule names**: Underscores → hyphens (match query naming)
   - `type_coverage` → `type-coverage`
   - `docstring_coverage` → `docstring-coverage`
   - `param_complexity` → `param-complexity`

2. **Field names**: `display_name` → `description` (match Query base class)
   - Updated QualityRule abstract base class
   - Updated all three rule implementations
   - Follows query system pattern with sentence case descriptions

3. **Config keys**: TOML sections use hyphens
   - `[quality.type-coverage]` (not `[quality.type_coverage]`)
   - Consistent with hyphenated rule names

**Implementation Updates:**

- Updated config loader to use hyphenated section names
- Updated console formatters to replace hyphens with spaces (not underscores)
- Updated all tests (76 tests passing)
- Updated all documentation (user journey, interface docs)
- Removed unnecessary `__all__` documentation comment per feedback

**Why this matters:**

- Query names use hyphens: `find-dead-code`, `analyze-call-complexity`
- Quality names now match: `type-coverage`, `docstring-coverage`
- CLI commands already used hyphens: `mapper quality type-coverage`
- Provides consistent developer experience across system

All 273 unit tests passing, linting clean (ruff, mypy, isort).

Closes #85 (comment: consistent naming feedback)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@octo-youcef
octo-youcef force-pushed the feature/quality-rules branch from 0217c35 to cec7bc5 Compare April 13, 2026 05:34
@octo-youcef

Copy link
Copy Markdown
Collaborator Author

🔄 Rebased to Clean Commit History

Force-pushed rebased commits with cleaned history:

5 logical commits:

  1. a0598cd - Add user journey for quality rules (v0.8.1)
  2. e68dcec - Add interface design for quality rules (v0.8.1)
  3. 97c62fa - Add quality rule models and configuration schema
  4. 67925cc - Add Neo4j queries for each quality rule
  5. cec7bc5 - Add output formatters for quality results (console, JSON, CSV)

What was squashed:

  • Param complexity addition → squashed into user journey
  • Attrs/ABC/registry feedback → squashed into Neo4j queries commit
  • Fixture consolidation → squashed into Neo4j queries commit
  • Formatting fixes → squashed into formatters commit
  • Naming consistency fixes → squashed into formatters commit
  • Documentation cleanup → squashed into formatters commit

All checks passing:

  • ✅ 273 unit tests passing
  • ✅ Linting clean (ruff, mypy, isort)

Monitoring CI status...

@octo-youcef

Copy link
Copy Markdown
Collaborator Author

✅ CI Passed!

All checks completed successfully:

  • lint - SUCCESS
  • test (3.10) - SUCCESS
  • test (3.11) - SUCCESS
  • test (3.12) - SUCCESS
  • integration (3.10) - SUCCESS
  • integration (3.11) - SUCCESS
  • integration (3.12) - SUCCESS
  • GitGuardian Security Checks - SUCCESS

Clean commit history pushed, all tests passing. Ready for final review! 🎉

@octo-youcef

Copy link
Copy Markdown
Collaborator Author

📦 Version Bumped to 0.8.1

3 new commits:

  1. 6cb6c8e - Update documentation for v0.8.1 release
  2. 776fefa - Bump version: 0.8.0 → 0.8.1
  3. 44414c6 - Update CLAUDE.md current version to 0.8.1

Changes:

  • ✅ CHANGELOG.md updated with v0.8.1 entry
  • ✅ README.md updated with quality rules examples
  • ✅ Version bumped in pyproject.toml, src/mapper/init.py, README badge
  • ✅ CLAUDE.md current version updated
  • ✅ All 273 unit tests passing

Monitoring CI status...

@octo-youcef

Copy link
Copy Markdown
Collaborator Author

✅ CI Passed - Ready to Merge!

All checks completed successfully after version bump:

  • lint - SUCCESS
  • test (3.10, 3.11, 3.12) - SUCCESS
  • integration (3.10, 3.11, 3.12) - SUCCESS
  • GitGuardian Security Checks - SUCCESS

Final commit history (8 commits):

  1. Add user journey for quality rules (v0.8.1)
  2. Add interface design for quality rules (v0.8.1)
  3. Add quality rule models and configuration schema
  4. Add Neo4j queries for each quality rule
  5. Add output formatters for quality results (console, JSON, CSV)
  6. Update documentation for v0.8.1 release
  7. Bump version: 0.8.0 → 0.8.1
  8. Update CLAUDE.md current version to 0.8.1

Version: 0.8.1
Tests: 273 passing
Status: Ready to merge 🎉

@octo-youcef

Copy link
Copy Markdown
Collaborator Author

✅ CHANGELOG Fixed - CI Passed!

Fixed duplicate 0.8.1 entry in CHANGELOG.md.

Final commit: e26e916 - Fix duplicate 0.8.1 entry in CHANGELOG

All checks passing:

  • lint - SUCCESS
  • test (3.10, 3.11, 3.12) - SUCCESS
  • integration (3.10, 3.11, 3.12) - SUCCESS
  • GitGuardian Security Checks - SUCCESS

Ready to merge! 🎉

octo-youcef and others added 3 commits April 13, 2026 21:02
Add CHANGELOG entry for v0.8.1 with quality rules features:
- Built-in quality rules (type-coverage, docstring-coverage, param-complexity)
- Quality check output formats (console, JSON, CSV)
- Quality configuration system via mapper.toml
- User journey and interface documentation

Update README.md:
- Add quality rules to key features
- Add quality check examples to basic usage

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@octo-youcef
octo-youcef force-pushed the feature/quality-rules branch from e26e916 to 5186dd2 Compare April 13, 2026 09:04
@octo-youcef

Copy link
Copy Markdown
Collaborator Author

🔄 Rebased - CHANGELOG Fix Squashed

Rebased to squash the CHANGELOG fixup commit into the version bump commit.

Final clean history (8 commits):

  1. a0598cd - Add user journey for quality rules (v0.8.1)
  2. e68dcec - Add interface design for quality rules (v0.8.1)
  3. 97c62fa - Add quality rule models and configuration schema
  4. 67925cc - Add Neo4j queries for each quality rule
  5. cec7bc5 - Add output formatters for quality results (console, JSON, CSV)
  6. d600e9e - Update documentation for v0.8.1 release
  7. 7fa2d4b - Bump version: 0.8.0 → 0.8.1 (now includes CHANGELOG fix)
  8. 5186dd2 - Update CLAUDE.md current version to 0.8.1

Verified:

  • ✅ 273 unit tests passing
  • ✅ CHANGELOG has single 0.8.1 entry

Monitoring CI...

@octo-youcef

Copy link
Copy Markdown
Collaborator Author

✅ CI Passed - Ready to Merge!

All checks passing after rebase:

  • lint - SUCCESS
  • test (3.10, 3.11, 3.12) - SUCCESS
  • integration (3.10, 3.11, 3.12) - SUCCESS
  • GitGuardian Security Checks - SUCCESS

Final status:

  • 8 clean commits
  • Single 0.8.1 entry in CHANGELOG
  • Version 0.8.1
  • 273 tests passing

Ready to merge! 🎉

@ydkadri
ydkadri merged commit 84e7079 into main Apr 13, 2026
8 checks passed
ydkadri pushed a commit that referenced this pull request Apr 13, 2026
Implement three formatters for quality rule results to support different
output contexts:

**Console Formatter**:
- Human-readable output with Rich markup (colors, symbols)
- Check marks (✓/✗) for pass/fail status
- Single result: detailed breakdown with file-level data and violations
- Multiple results: summary view with overall pass/fail count

**JSON Formatter**:
- Structured JSON arrays for CI/CD integration
- Different schemas for coverage vs complexity rules
- Indented output (jq-compatible)

**CSV Formatter**:
- Spreadsheet-compatible output for tracking over time
- Coverage schema: rule,file_path,total_functions,compliant_functions,compliance_percentage,status
- Complexity schema: rule,file_path,function_name,line_number,parameter_count,status
- Separate headers for mixed result types

**Pattern**:
- OutputFormat(str, Enum) for type-safe format selection
- FormatsQualityResults protocol defining formatter interface
- get_formatter() factory function with match/case

**Type Annotation Updates**:
- Modernize Optional[X] → X | None throughout quality package
- Modernize Union[X, Y] → X | Y for Python 3.10+ syntax

**Tests**: 23 new tests in test_quality_formatters.py
- All three formatters with both result types
- Single vs multiple result formatting
- Edge cases (empty results, no violations)
- Enum string compatibility

All 76 quality tests passing, linting clean (ruff, mypy, isort).

Part of v0.8.1 - Built-in Quality Rules (Commit 3/6).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Clarify __all__ is only for __init__.py files

Remove __all__ from regular modules (only keep in __init__.py):
- src/mapper/quality/models.py
- src/mapper/quality/config.py
- src/mapper/quality/registry.py
- src/mapper/quality/rules/type_coverage.py
- src/mapper/quality/rules/docstring_coverage.py
- src/mapper/quality/rules/param_complexity.py

Keep __all__ in:
- src/mapper/quality/__init__.py (package entry point)
- src/mapper/quality/rules/__init__.py (package entry point)

Update code-architecture.md:
- Add explicit note: __all__ is ONLY for __init__.py files
- Show example of regular module WITHOUT __all__
- Clarify that regular modules use underscore prefixes for private items

All 53 quality tests passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Apply ruff formatting to test files

Auto-formatting applied to test_param_complexity_rule.py and
test_type_coverage_rule.py for line length compliance.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Address PR feedback: consistent naming and field conventions

Make quality rule names and fields consistent with query system
patterns to improve codebase uniformity and developer experience.

**Naming Convention Changes:**

1. **Rule names**: Underscores → hyphens (match query naming)
   - `type_coverage` → `type-coverage`
   - `docstring_coverage` → `docstring-coverage`
   - `param_complexity` → `param-complexity`

2. **Field names**: `display_name` → `description` (match Query base class)
   - Updated QualityRule abstract base class
   - Updated all three rule implementations
   - Follows query system pattern with sentence case descriptions

3. **Config keys**: TOML sections use hyphens
   - `[quality.type-coverage]` (not `[quality.type_coverage]`)
   - Consistent with hyphenated rule names

**Implementation Updates:**

- Updated config loader to use hyphenated section names
- Updated console formatters to replace hyphens with spaces (not underscores)
- Updated all tests (76 tests passing)
- Updated all documentation (user journey, interface docs)
- Removed unnecessary `__all__` documentation comment per feedback

**Why this matters:**

- Query names use hyphens: `find-dead-code`, `analyze-call-complexity`
- Quality names now match: `type-coverage`, `docstring-coverage`
- CLI commands already used hyphens: `mapper quality type-coverage`
- Provides consistent developer experience across system

All 273 unit tests passing, linting clean (ruff, mypy, isort).

Closes #85 (comment: consistent naming feedback)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ydkadri
ydkadri deleted the feature/quality-rules branch April 13, 2026 09:30
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.

2 participants