Skip to content

refactor(ssm): split update_document and list_documents in documents.rs#358

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-ssm-documents-long-fns
Apr 13, 2026
Merged

refactor(ssm): split update_document and list_documents in documents.rs#358
vieiralucas merged 1 commit intomainfrom
worktree-cleanup-ssm-documents-long-fns

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

  • `update_document`: extract `validate_update_document_target_version`, `validate_update_document_unique_content` (the per-version SHA-256 dedupe check), and `validate_update_document_unique_version_name`. The outer function now reads as parse → 3 named validators → mutate → render instead of inlining the validation logic between the lookup and the version push.
  • `list_documents`: extract `document_matches_list_filters` (Owner / TargetType / Name filter dispatch — was a 30-line nested for-loop+match inside a closure) and `document_identifier_json` (the `DocumentIdentifier` JSON shape). The outer function is now a 12-line filter+paginate flow.

Test plan

  • `cargo fmt`
  • `cargo clippy -p fakecloud-ssm --all-targets -- -D warnings`
  • `cargo test -p fakecloud-ssm --lib` — 60 passed
  • `cargo test --workspace --exclude fakecloud-e2e --exclude fakecloud-conformance`

Summary by cubic

Refactored fakecloud-ssm documents service by splitting update_document and list_documents into small helpers for validation, filtering, and JSON shaping. Flows are now parse → validate → mutate → render and filter → paginate, with no behavior changes.

  • Refactors
    • update_document: extracted validate_update_document_target_version, validate_update_document_unique_content (SHA-256 dedupe), and validate_update_document_unique_version_name.
    • list_documents: extracted document_matches_list_filters (Owner/TargetType/Name) and document_identifier_json.

Written for commit cd6026d. Summary will update on new commits.

- update_document: extract validate_update_document_target_version,
  validate_update_document_unique_content, and
  validate_update_document_unique_version_name. The outer function now
  reads as parse → 3 named validators → mutate → render.
- list_documents: extract document_matches_list_filters (Owner/TargetType/Name
  filter dispatch) and document_identifier_json (DocumentIdentifier shape).
  The outer function is now a 12-line filter+paginate flow.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@vieiralucas vieiralucas merged commit 6d1d4e1 into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup-ssm-documents-long-fns branch April 13, 2026 16:05
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.

1 participant