Skip to content

Claude/refactor main function#21

Merged
click0 merged 2 commits into
mainfrom
claude/refactor-main-function
Apr 13, 2026
Merged

Claude/refactor main function#21
click0 merged 2 commits into
mainfrom
claude/refactor-main-function

Conversation

@click0
Copy link
Copy Markdown
Owner

@click0 click0 commented Apr 13, 2026

No description provided.

claude added 2 commits March 26, 2026 06:37
- Replace broad `except Exception` with specific exception types across
  all scripts (data_masking.py, unmask_data.py, diagnose_mapping.py,
  modules/config.py, modules/tools.py)
- Add debug logging to empty `except ImportError: pass` blocks for
  optional module imports
- Add file size validation (100 MB limit) before reading files into
  memory to prevent DoS
- Add mapping file schema validation (validate_mapping_schema) in
  unmask_data.py
- Add missing logger calls alongside warning/error print() statements
- Add configurable masking parameters to MaskingRulesConfig (rank_shift,
  date_shift, brigade range, etc.)
- Add missing type hints (tools.py, diagnose_mapping.py, unmask_data.py)
- Add .pre-commit-config.yaml (flake8, isort, mypy, trailing whitespace)
- Add mypy.ini with per-module configuration
- Create CHANGELOG.md with full version history
- Add tests for masking_logger (JsonFormatter, ConsoleFormatter,
  MaskingLogger, file logging)
- Add tests for selective module (filters, aliases, groups, roundtrips)
- Add tests for password_generator (generate, config, constants, variety)

All 397 tests pass.

https://claude.ai/code/session_01KpVjBebKBWKQauU4YR5KhH
Split the ~500-line main() function in data_masking.py into 12
well-named helper functions, each with a single responsibility:

- _build_parser() — CLI argument parser setup
- _load_config() — YAML config loading with error handling
- _setup_logger() — structured logging initialization
- _apply_selective_filters() — --only/--exclude filter application
- _apply_config_settings() — config-based masking rules and system settings
- _prepare_output_paths() — output/map/report path computation
- _read_input() — file reading with size validation
- _run_masking() — masking pipeline dispatcher
- _run_multi_pass_masking() — multi-pass re-masking with chain tracking
- _run_single_pass_masking() — single-pass masking
- _handle_encryption() — mapping file encryption
- _write_report() — detailed report generation
- _print_summary() — console output summary
- _save_results() — orchestrates saving output, mapping, encryption, report

The refactored main() is now ~80 lines and reads as a clear pipeline.
All 397 tests pass with no behavioral changes.

https://claude.ai/code/session_01KpVjBebKBWKQauU4YR5KhH
@click0 click0 merged commit 5c41d80 into main Apr 13, 2026
1 check passed
@click0 click0 deleted the claude/refactor-main-function branch April 13, 2026 12:29
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