Skip to content

[cpf fmt] Create package to format CPF - #22

Merged
juliolmuller merged 10 commits into
mainfrom
feat/cpf-fmt
Jul 21, 2026
Merged

[cpf fmt] Create package to format CPF#22
juliolmuller merged 10 commits into
mainfrom
feat/cpf-fmt

Conversation

@juliolmuller

@juliolmuller juliolmuller commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Released the stable cpf-fmt Ruby gem with CPF formatting/normalization, delimiter customization, privacy masking, HTML escaping and/or URL encoding, plus consistent failure handling.
    • Added CpfFmt::CpfFormatter and the CpfFmt.cpf_fmt convenience helper.
  • Documentation
    • Added full English and Portuguese READMEs and a 1.0.0 changelog entry for cpf-fmt.
    • Reordered documented error types in related READMEs (presentation only).
  • Tests
    • Expanded RSpec coverage for formatting, options precedence/validation, input normalization, masking, post-processing, and error behavior.

juliolmuller and others added 6 commits July 21, 2026 13:18
- Revised summary and description to clarify the purpose of the gem as a formatter of CPF (Brazilian Individual's Taxpayer ID).
- Removed changelog URI from metadata for simplification.

Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@juliolmuller
juliolmuller requested a review from a team as a code owner July 21, 2026 17:54
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 88aa1b73-0241-43fa-bafa-237c8c8fa050

📥 Commits

Reviewing files that changed from the base of the PR and between 0d25e89 and f02cbda.

📒 Files selected for processing (8)
  • packages/cnpj-fmt/README.md
  • packages/cnpj-fmt/README.pt.md
  • packages/cnpj-gen/README.md
  • packages/cnpj-gen/README.pt.md
  • packages/cnpj-val/README.md
  • packages/cnpj-val/README.pt.md
  • packages/cpf-fmt/README.md
  • packages/cpf-fmt/README.pt.md

📝 Walkthrough

Walkthrough

The PR replaces the placeholder CPF gem with a complete Ruby formatter, including input normalization, configurable masking and delimiters, post-processing, option merging, structured errors, public APIs, documentation, and comprehensive RSpec coverage.

Changes

CPF formatter implementation

Layer / File(s) Summary
Contracts, errors, and option resolution
packages/cpf-fmt/src/cpf-fmt/types.rb, packages/cpf-fmt/src/cpf-fmt/errors.rb, packages/cpf-fmt/src/cpf-fmt/cpf_formatter_options.rb, packages/cpf-fmt/tests/*
Adds public types, custom errors, validated options, layered precedence, copying, partial updates, and tests.
Input normalization and transformations
packages/cpf-fmt/src/cpf-fmt/utils.rb, packages/cpf-fmt/tests/utils.spec.rb
Adds input coercion, sanitization, masking, delimiters, escaping, encoding, and failure callbacks.
Formatter and convenience API
packages/cpf-fmt/src/cpf-fmt/cpf_formatter.rb, packages/cpf-fmt/src/cpf-fmt/cpf_fmt.rb, packages/cpf-fmt/tests/*
Adds formatter orchestration, per-call overrides, invalid-length handling, and CpfFmt.cpf_fmt.
Entrypoint and release documentation
packages/cpf-fmt/src/cpf-fmt.rb, packages/cpf-fmt/README*, packages/cpf-fmt/CHANGELOG.md, packages/cpf-fmt/cpf-fmt.gemspec, packages/cnpj-*/README*
Loads the implementation, replaces CpfFmt.hello, updates metadata and documentation, records version 1.0.0, and reorders related error lists.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant CpfFmt
  participant CpfFormatter
  participant Utils
  Caller->>CpfFmt: call cpf_fmt(cpf_input, options)
  CpfFmt->>CpfFormatter: construct and format
  CpfFormatter->>Utils: normalize and sanitize CPF
  Utils-->>CpfFormatter: sanitized digits
  CpfFormatter->>Utils: mask, delimit, escape, or encode
  Utils-->>CpfFormatter: formatted CPF
  CpfFormatter-->>Caller: return result or on_fail output
Loading

Possibly related issues

  • Issue 8 — Covers the cpf-fmt formatter implementation introduced by this PR.
  • Issue 11 — Covers the CPF formatting package, APIs, options, errors, and tests.
  • Issue 5 — Covers equivalent CPF formatter functionality in the Java package.

Suggested labels: enhancement

Poem

I’m a rabbit with digits aligned,
Dots and dashes neatly designed.
Masks hide what should stay unseen,
Errors speak clearly and clean.
Options hop in a predictable stream—
CPF formatting fulfills the dream!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.84% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: adding a CPF formatting package.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cpf-fmt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@juliolmuller juliolmuller linked an issue Jul 21, 2026 that may be closed by this pull request
@coderabbitai coderabbitai Bot added the enhancement New minor or major features. label Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cpf-fmt/README.md`:
- Around line 235-242: Reorder the summary table rows alphabetically within each
category by placing CpfFmt::InvalidArgumentCombinationError before
CpfFmt::TypeMismatchError. Apply this row swap in packages/cpf-fmt/README.md
lines 235-242 and packages/cpf-fmt/README.pt.md lines 222-229; leave the
domain-error rows unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1fab7430-e69f-4377-9ece-f36fdfda8651

📥 Commits

Reviewing files that changed from the base of the PR and between 51972f0 and 0d25e89.

📒 Files selected for processing (16)
  • packages/cpf-fmt/CHANGELOG.md
  • packages/cpf-fmt/README.md
  • packages/cpf-fmt/README.pt.md
  • packages/cpf-fmt/cpf-fmt.gemspec
  • packages/cpf-fmt/src/cpf-fmt.rb
  • packages/cpf-fmt/src/cpf-fmt/cpf_fmt.rb
  • packages/cpf-fmt/src/cpf-fmt/cpf_formatter.rb
  • packages/cpf-fmt/src/cpf-fmt/cpf_formatter_options.rb
  • packages/cpf-fmt/src/cpf-fmt/errors.rb
  • packages/cpf-fmt/src/cpf-fmt/types.rb
  • packages/cpf-fmt/src/cpf-fmt/utils.rb
  • packages/cpf-fmt/tests/cpf_fmt.spec.rb
  • packages/cpf-fmt/tests/cpf_formatter.spec.rb
  • packages/cpf-fmt/tests/cpf_formatter_options.spec.rb
  • packages/cpf-fmt/tests/errors.spec.rb
  • packages/cpf-fmt/tests/utils.spec.rb

Comment thread packages/cpf-fmt/README.md
juliolmuller and others added 4 commits July 21, 2026 15:56
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@juliolmuller
juliolmuller merged commit 3298142 into main Jul 21, 2026
71 checks passed
@juliolmuller
juliolmuller deleted the feat/cpf-fmt branch July 21, 2026 19:13
juliolmuller added a commit that referenced this pull request Jul 21, 2026
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
juliolmuller added a commit that referenced this pull request Jul 21, 2026
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
juliolmuller added a commit that referenced this pull request Jul 21, 2026
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
juliolmuller added a commit that referenced this pull request Jul 21, 2026
Adjustment as per @coderabbitai review comment at #22 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New minor or major features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement package cpf-fmt

1 participant