Skip to content

Add ACARS free-text cleanup helper#457

Open
MillsyTheKiwi wants to merge 3 commits into
airframesio:masterfrom
MillsyTheKiwi:master
Open

Add ACARS free-text cleanup helper#457
MillsyTheKiwi wants to merge 3 commits into
airframesio:masterfrom
MillsyTheKiwi:master

Conversation

@MillsyTheKiwi

@MillsyTheKiwi MillsyTheKiwi commented Jun 23, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Implemented emergency squawk code recognition and lookup for codes 7500, 7600, and 7700 with human-readable meanings
    • Enhanced ACARS message decoding with improved free-text normalization that collapses whitespace and trims unnecessary characters
  • Tests

    • Added test coverage for emergency squawk code utilities and text formatting functions

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@MillsyTheKiwi, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 minutes and 24 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f81499e8-9cf7-4552-af9c-b0f653845aad

📥 Commits

Reviewing files that changed from the base of the PR and between 73f2bcb and 486a35c.

📒 Files selected for processing (5)
  • lib/plugins/Label_5Z_Slash.ts
  • lib/utils/acars_free_text.test.ts
  • lib/utils/acars_free_text.ts
  • lib/utils/emergency_squawk.test.ts
  • lib/utils/emergency_squawk.ts

Walkthrough

Two new utility modules are added: formatAcarsFreeText (normalizes whitespace in ACARS free-text strings) and an emergency squawk module (type definitions, lookup map, and helpers for codes 7500/7600/7700). Label_5Z_Slash is updated to apply formatAcarsFreeText to /TXT payloads before formatting. Both utilities include Jest test suites.

Changes

ACARS Free-Text Formatter and Label_5Z_Slash Integration

Layer / File(s) Summary
formatAcarsFreeText utility and tests
lib/utils/acars_free_text.ts, lib/utils/acars_free_text.test.ts
Adds formatAcarsFreeText returning '' for falsy input and trimming/collapsing whitespace otherwise; tests verify normalization and null/undefined safety.
Integration into Label_5Z_Slash /TXT branch
lib/plugins/Label_5Z_Slash.ts
Imports formatAcarsFreeText and pipes the joined free-text lines through it before passing to ResultFormatter.text in the /TXT decode path.

Emergency Squawk Utility Module

Layer / File(s) Summary
Emergency squawk types, helpers, and tests
lib/utils/emergency_squawk.ts, lib/utils/emergency_squawk.test.ts
Exports EmergencySquawkCode (7500/7600/7700), EmergencySquawkInfo, and three helpers (getEmergencySquawkInfo, isEmergencySquawk, formatEmergencySquawk) backed by a static map; tests cover all three valid codes and an unknown code (1234).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • kevinelliott

Poem

🐇 A bunny hops through squawk codes galore,
7500, 7600, and 7700 no more a bore!
Free text is trimmed with a neat little snap,
Extra spaces collapse with a satisfying tap.
The formatter runs clean — no whitespace astray,
Another smooth landing in the ACARS relay! ✈️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Add ACARS free-text cleanup helper' accurately describes the primary change: adding the formatAcarsFreeText utility function and its integration into Label_5Z_Slash, with supporting tests.
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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (1)
lib/utils/emergency_squawk.ts (1)

20-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider deriving validation from SQUAWK_MAP.

The manual check against the three codes duplicates the knowledge already encoded in SQUAWK_MAP. If a new emergency squawk code is added to the map in the future, this function would need to be updated separately, creating a maintenance burden.

♻️ Refactor to eliminate duplication
 export function isEmergencySquawk(code: number): boolean {
-  return code === 7500 || code === 7600 || code === 7700;
+  return code in SQUAWK_MAP;
 }
🤖 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 `@lib/utils/emergency_squawk.ts` around lines 20 - 22, The isEmergencySquawk
function hardcodes the emergency squawk codes (7500, 7600, 7700) instead of
deriving them from SQUAWK_MAP, creating maintenance duplication. Refactor the
function to check if the provided code exists in SQUAWK_MAP and has an emergency
classification, rather than using hardcoded equality checks. This way, adding
new emergency squawk codes to SQUAWK_MAP will automatically be reflected in the
validation logic without requiring separate function updates.
🤖 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 `@lib/plugins/Label_5Z_Slash.ts`:
- Around line 52-60: The code block containing the ResultFormatter.text()
function call and subsequent statements has inconsistent indentation that
violates Prettier formatting rules. Fix the indentation of the entire block
starting from the comment "not UA, but starts with `/`" through the return
statement by properly aligning the ResultFormatter.text() function call
parameters and all following lines to comply with Prettier's indentation
standards.

In `@lib/utils/acars_free_text.test.ts`:
- Line 13: The test file acars_free_text.test.ts is missing a trailing newline
at the end of the file, which causes the prettier linter to fail. Add a single
newline character at the very end of the file after the final closing brace and
parenthesis `});` to satisfy the prettier formatting requirement.

In `@lib/utils/acars_free_text.ts`:
- Line 4: The file lib/utils/acars_free_text.ts is missing a trailing newline at
the end, which causes Prettier linting to fail. Add a newline character after
the closing brace on the last line of the file to satisfy the Prettier
formatting requirement.

In `@lib/utils/emergency_squawk.test.ts`:
- Around line 1-44: The test file emergency_squawk.test.ts is missing a newline
at the end of the file. Add a newline character after the final closing brace of
the describe block to comply with linting standards. You can do this manually by
placing your cursor at the very end of the file (after the last closing brace)
and adding a newline, or run prettier --write on the file to auto-fix this
formatting issue.

In `@lib/utils/emergency_squawk.ts`:
- Around line 1-27: The emergency_squawk.ts file has prettier formatting
inconsistencies in the getEmergencySquawkInfo function signature (around line
14) and in the formatEmergencySquawk function's ternary expression and final
newline handling (around lines 26-27). Run prettier --write on the
emergency_squawk.ts file to automatically apply the correct formatting according
to the project's prettier configuration, which will fix the multi-line function
signature formatting and the ternary expression/newline issues.

---

Nitpick comments:
In `@lib/utils/emergency_squawk.ts`:
- Around line 20-22: The isEmergencySquawk function hardcodes the emergency
squawk codes (7500, 7600, 7700) instead of deriving them from SQUAWK_MAP,
creating maintenance duplication. Refactor the function to check if the provided
code exists in SQUAWK_MAP and has an emergency classification, rather than using
hardcoded equality checks. This way, adding new emergency squawk codes to
SQUAWK_MAP will automatically be reflected in the validation logic without
requiring separate function updates.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 879f8410-1a14-4194-a08a-3f8569941b7e

📥 Commits

Reviewing files that changed from the base of the PR and between 2157d67 and 73f2bcb.

📒 Files selected for processing (5)
  • lib/plugins/Label_5Z_Slash.ts
  • lib/utils/acars_free_text.test.ts
  • lib/utils/acars_free_text.ts
  • lib/utils/emergency_squawk.test.ts
  • lib/utils/emergency_squawk.ts

Comment thread lib/plugins/Label_5Z_Slash.ts Outdated
Comment thread lib/utils/acars_free_text.test.ts Outdated
Comment thread lib/utils/acars_free_text.ts Outdated
Comment thread lib/utils/emergency_squawk.test.ts Outdated
Comment thread lib/utils/emergency_squawk.ts Outdated
@MillsyTheKiwi

Copy link
Copy Markdown
Author

I’ve addressed the review feedback and the branch is ready. The only remaining blocker appears to be workflow approval.

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