Skip to content

chore(credo): clear strict warnings#104

Merged
yordis merged 2 commits into
mainfrom
yordis/chore-clear-credo-strict-warnings
May 14, 2026
Merged

chore(credo): clear strict warnings#104
yordis merged 2 commits into
mainfrom
yordis/chore-clear-credo-strict-warnings

Conversation

@yordis

@yordis yordis commented May 14, 2026

Copy link
Copy Markdown
Member
  • Without this, every PR has to ship paired credo cleanups on files it never touched, conflating reviews.
  • Three categories drained: alias ordering in test modules (11), nested function bodies via extract-helper / flatten-comprehension (8), and length/1 emptiness checks (2).

CI's mix credo --strict gate is the source of truth for style; resolving
the long tail of warnings now keeps future PRs reviewable without action
items unrelated to the change at hand.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor

cursor Bot commented May 14, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Low risk refactor focused on extracting small helper functions and simplifying test assertions; intended to be behavior-preserving in core command dispatch, aggregate multi execution, and Ecto batch projection code.

Overview
Refactors a few nested blocks into private helpers to satisfy Credo strict checks: aggregate command execution now delegates Multi handling to run_multi/4, Ecto batch projections extract prepare_user_multi/3, and the router macro factors duplicate-command detection into Router.__check_command_not_registered__/3 using List.keymember?/3.

Cleans up tests to eliminate strict warnings by reordering aliases, flattening nested for comprehensions used for telemetry detaches, and replacing length(...) >= 1 with non-empty checks.

Reviewed by Cursor Bugbot for commit 7d94b46. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Rate limit exceeded

@yordis has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 46 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 79e85386-a4b0-4954-8e01-f549cb28e628

📥 Commits

Reviewing files that changed from the base of the PR and between 7d2e310 and 7d94b46.

📒 Files selected for processing (1)
  • lib/commanded/commands/router.ex

Walkthrough

This PR refactors core library functions to extract internal helpers and improves test infrastructure. It extends CI workflow commit types, extracts Multi handling and validation logic into reusable helpers, refactors telemetry assertions, and normalizes test import declarations across the suite.

Changes

Refactoring and test cleanup

Layer / File(s) Summary
CI workflow commit types
.github/workflows/ci.yml
Conventional Commits check now allows refactor, test, and docs commit types in addition to existing feat, fix, and chore.
Aggregate Multi handling extraction
lib/commanded/aggregates/aggregate.ex
execute_command/3 delegates %Multi{} result handling to new private run_multi/4 helper, which encapsulates error propagation and delegates successful results to persist_events/5.
Router command registration check extraction
lib/commanded/commands/router.ex
Duplicate command registration validation extracted from dispatch/2 macro into module function __check_command_not_registered__/3, preserving identical membership test and error behavior.
Projection multi preparation extraction
lib/commanded/projections/ecto.ex
execute_batch_projection/2 delegates unseen-events extraction and Ecto.Multi validation to new helper prepare_user_multi/3, replacing inline anonymous function logic.
Distributed subscribers per-node helpers
test/subscriptions/support/distributed_subscribers.ex
start_subscribers/1 and query_subscriptions/1 extract per-node setup and query work into private helpers start_subscribers_on_node/2 and query_subscriptions_on_node/2.
Telemetry test improvements
test/opentelemetry/aggregate_populate_test.exs, test/opentelemetry/aggregate_snapshot_test.exs, test/opentelemetry/aggregate_test.exs, test/opentelemetry/event_store_test.exs
Telemetry handler attachment assertions simplified to use direct list non-emptiness (handlers != []); handler detachment loops refactored to flattened comprehensions over events, suffixes, and handlers.
Test import normalization
test/aggregates/aggregate_concurrency_test.exs, test/aggregates/aggregate_lifespan_test.exs, test/aggregates/execute_command_test.exs, test/application/telemetry_test.exs, test/commands/correlation_causation_test.exs, test/event/event_handler_batch_test.exs, test/event/event_handler_telemetry_test.exs, test/event_store/adapters/in_memory/in_memory_test.exs, test/event_store/support/adapter_test_data.ex, test/event_store/telemetry_test.exs
Module alias declarations expanded from grouped imports to individual statements and reordered for consistency across test suite.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • straw-hat-team/commanded#45: Introduces OpenTelemetry aggregate test instrumentation that this PR refactors to use flattened comprehensions in handler detachment.
  • straw-hat-team/commanded#47: Adds aggregate-populate OpenTelemetry instrumentation whose handler attachment assertions are simplified in this PR.
  • straw-hat-team/commanded#37: Introduces OpenTelemetry EventStore instrumentation whose test cleanup patterns align with this PR's telemetry handler refactoring.

Poem

🐰 With helpers extracted and tests aligned,
The code becomes cleaner, more refined.
Aliases ordered, assertions lean,
The prettiest refactor I've ever seen!
Hop along, committed code so bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% 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
Title check ✅ Passed The title 'chore(credo): clear strict warnings' accurately and specifically describes the main objective of this PR—clearing accumulated Credo strict warnings across multiple files.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation (avoiding style-fix bloat in future PRs) and categorizing the three types of warnings addressed (alias ordering, nested functions, and length checks).
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/chore-clear-credo-strict-warnings

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 and usage tips.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis force-pushed the yordis/chore-clear-credo-strict-warnings branch from 7d2e310 to 7d94b46 Compare May 14, 2026 19:21
@yordis yordis merged commit b79ddcb into main May 14, 2026
5 checks passed
@yordis yordis deleted the yordis/chore-clear-credo-strict-warnings branch May 14, 2026 19:26
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