Skip to content

Fix supported command on Elixir modules#9

Merged
UncleGrumpy merged 1 commit into
mainfrom
elixir-support
May 31, 2026
Merged

Fix supported command on Elixir modules#9
UncleGrumpy merged 1 commit into
mainfrom
elixir-support

Conversation

@UncleGrumpy
Copy link
Copy Markdown
Owner

Correctly report Elixir modules as supported when the 'Elixir' prefix is ommited.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 00e34900-16ca-4ac1-8edd-208640d01d1a

📥 Commits

Reviewing files that changed from the base of the PR and between 1c36b49 and 5fdb2ab.

📒 Files selected for processing (6)
  • src/atomvm_spectrometer.erl
  • src/spectrometer_help.erl
  • src/spectrometer_utils.erl
  • test/atomvm_spectrometer_tests.erl
  • test/spectrometer_elixir_tests.erl
  • test/spectrometer_utils_tests.erl
✅ Files skipped from review due to trivial changes (1)
  • test/spectrometer_utils_tests.erl
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/atomvm_spectrometer_tests.erl
  • src/atomvm_spectrometer.erl
  • src/spectrometer_help.erl

📝 Walkthrough

Walkthrough

This PR changes Elixir module-name handling: it uses the two-argument normalizer (with an Elixir flag) in spectrometer_utils, applies that normalization in the CLI for --module/-m, updates help text with examples, and adds/updates EUnit tests validating the behavior.

Changes

Elixir Module Normalization and CLI Integration

Layer / File(s) Summary
Elixir module normalization contract
src/spectrometer_utils.erl
Export list removes normalize_module_name/1; is_elixir_module_name/1 now normalizes list/binary inputs with normalize_module_name(..., true) and checks for the <<"Elixir.", _/binary>> prefix.
CLI argument parsing using normalization
src/atomvm_spectrometer.erl
parse_supported_args/2 now passes true to spectrometer_utils:normalize_module_name/2 for both --module and -m.
Help documentation and examples
src/spectrometer_help.erl
Added help line noting Elixir modules may omit the Elixir. prefix and examples showing both Elixir.List and List forms for -m.
Test coverage for normalization and CLI parsing
test/atomvm_spectrometer_tests.erl, test/spectrometer_elixir_tests.erl, test/spectrometer_utils_tests.erl
Added a new EUnit test for CLI parsing of -m/--module; updated tests to cover normalize_module_name/2 flag behavior and is_elixir_module_name/1 case/binary handling; added test section header for organization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


Possibly related PRs


Poem

🐰 With a twitch and a hop I tidy the name,
Elixir and Erlang now play a fair game,
Capital letters get Elixir prefixed,
Lowercase modules remain as they’re fixed,
Tests hop along to confirm every claim.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix supported command on Elixir modules' directly relates to the main change: improving Elixir module detection when the 'Elixir.' prefix is omitted.
Description check ✅ Passed The description 'Correctly report Elixir modules as supported when the Elixir prefix is ommited' is clearly related to the changeset's core objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 elixir-support

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/spectrometer_elixir_tests.erl (1)

69-73: ⚡ Quick win

Add binary-input coverage for is_elixir_module_name/1.

The production change updated separate list and binary branches, but these assertions only hit string inputs. A quick <<"GPIO">> / <<"lists">> pair would cover the new binary path too.

🤖 Prompt for 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.

In `@test/spectrometer_elixir_tests.erl` around lines 69 - 73, The test is only
exercising the string branch of spectrometer_utils:is_elixir_module_name/1; add
assertions in is_elixir_module_name_case_test to also call
spectrometer_utils:is_elixir_module_name/1 with binary inputs (e.g. <<"GPIO">>
should assert true and <<"lists">> should assert false) so the new binary branch
is covered alongside the existing string assertions; keep the test name and
pattern and place the new ?assertEqual checks next to the existing calls.
test/atomvm_spectrometer_tests.erl (1)

458-475: ⚡ Quick win

Cover the --module Elixir path as well.

This new test only exercises -m, but the parser change touched both -m and --module. Adding one ["supported", "--module", "List"] assertion would lock down the long-form branch too.

🤖 Prompt for 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.

In `@test/atomvm_spectrometer_tests.erl` around lines 458 - 475, The test
parse_supported_args_elxir_module_test_() exercises only the short flag "-m" but
not the long form "--module"; update the test to also call
atomvm_spectrometer:parse_args with ["supported", "--module", "List"] and assert
(via maps:get(module, OptsX)) that the parsed module is <<"Elixir.List">> to
cover the long-form branch of the parser (also add a similar check for
already-prefixed "Elixir.List" and for lowercase "lists" if desired to mirror
the existing short-flag cases).
🤖 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 `@src/spectrometer_utils.erl`:
- Around line 412-418: Update the `@doc` for is_elixir_module_name/1 to reflect
the new semantics: describe that the function calls normalize_module_name(Bin,
true) and returns true not only when the normalized binary literally starts with
"Elixir." but also when normalization maps capitalized short names (e.g.,
"GPIO") into Elixir module names (i.e., normalization may prepend "Elixir." or
otherwise convert capitalized identifiers into Elixir module form). Reference
normalize_module_name/2 and is_elixir_module_name/1 in the doc so readers
understand the check is performed on the normalized result rather than the
original input.

---

Nitpick comments:
In `@test/atomvm_spectrometer_tests.erl`:
- Around line 458-475: The test parse_supported_args_elxir_module_test_()
exercises only the short flag "-m" but not the long form "--module"; update the
test to also call atomvm_spectrometer:parse_args with ["supported", "--module",
"List"] and assert (via maps:get(module, OptsX)) that the parsed module is
<<"Elixir.List">> to cover the long-form branch of the parser (also add a
similar check for already-prefixed "Elixir.List" and for lowercase "lists" if
desired to mirror the existing short-flag cases).

In `@test/spectrometer_elixir_tests.erl`:
- Around line 69-73: The test is only exercising the string branch of
spectrometer_utils:is_elixir_module_name/1; add assertions in
is_elixir_module_name_case_test to also call
spectrometer_utils:is_elixir_module_name/1 with binary inputs (e.g. <<"GPIO">>
should assert true and <<"lists">> should assert false) so the new binary branch
is covered alongside the existing string assertions; keep the test name and
pattern and place the new ?assertEqual checks next to the existing calls.
🪄 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: CHILL

Plan: Pro

Run ID: d8721942-7da4-4763-af7f-f31770f87a95

📥 Commits

Reviewing files that changed from the base of the PR and between 662b149 and 1c36b49.

📒 Files selected for processing (6)
  • src/atomvm_spectrometer.erl
  • src/spectrometer_help.erl
  • src/spectrometer_utils.erl
  • test/atomvm_spectrometer_tests.erl
  • test/spectrometer_elixir_tests.erl
  • test/spectrometer_utils_tests.erl

Comment thread src/spectrometer_utils.erl
Correctly report Elixir modules as supported when the 'Elixir' prefix is
ommited.

Signed-off-by: Winford <winford@object.stream>
@UncleGrumpy
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@UncleGrumpy UncleGrumpy merged commit a80821d into main May 31, 2026
8 checks passed
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