Skip to content

Extract Verbosity Filtering Logic #103

@josecelano

Description

@josecelano

Extract Verbosity Filtering Logic

Issue: This issue
Parent Epic: #102 - User Output Architecture Improvements
Related: Refactoring Plan - Proposal #0

Overview

Extract verbosity checking logic from UserOutput into a dedicated VerbosityFilter struct. This eliminates code duplication across all output methods and makes verbosity rules testable independently.

See detailed specification: docs/issues/extract-verbosity-filtering-logic.md (will be renamed after issue creation)

Implementation Plan

Phase 1: Create VerbosityFilter (30 minutes)

  • Create VerbosityFilter struct with level field
  • Implement new() constructor
  • Implement should_show() base method
  • Add convenience methods: should_show_progress(), should_show_errors(), etc.

Phase 2: Add Unit Tests (45 minutes)

  • Test should_show_progress() at different verbosity levels
  • Test should_show_errors() always returns true
  • Test general should_show() method
  • Verify edge cases and boundary conditions

Phase 3: Integrate with UserOutput (1 hour)

  • Replace verbosity: VerbosityLevel field with verbosity_filter: VerbosityFilter
  • Update UserOutput::new() constructor
  • Update UserOutput::with_writers() constructor
  • Update all output methods to use verbosity_filter.should_show_X()

Phase 4: Verify & Clean Up (30 minutes)

  • Run all existing tests and verify they pass
  • Run linters: cargo run --bin linter all
  • Review code for any remaining inline verbosity checks
  • Update module documentation if needed

Acceptance Criteria

Quality Checks:

  • Pre-commit checks pass: ./scripts/pre-commit.sh

Task-Specific Criteria:

  • VerbosityFilter struct created with all required methods
  • All inline verbosity checks replaced with filter method calls
  • Unit tests added for VerbosityFilter behavior
  • All existing tests still pass without modification
  • No breaking changes to public UserOutput API
  • Module documentation updated if needed

Estimated Time

Total: ~3 hours (conservative estimate with testing and verification)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions