-
-
Notifications
You must be signed in to change notification settings - Fork 15
Using ResultFormatter to set flight number #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using ResultFormatter to set flight number #224
Conversation
also minor fix to always return boolean
WalkthroughThe changes update test assertions across multiple Label plugin tests to include a new "Flight Number" field as the first item in the decoded output. Each test now expects an increased number of formatted items with shifted indices and updated validations for subsequent labels and values. Additionally, helper methods in the utils directory have been revised to provide boolean feedback on the decoding process and include early returns for invalid input, refining the extraction and formatting logic. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant H1Helper
participant ResultFormatter
Client->>H1Helper: decodeH1Message(message)
alt Decoding Fails
H1Helper -->> Client: return false
else Decoding Succeeds
H1Helper->>H1Helper: processIdentification(data)
H1Helper->>ResultFormatter: flightNumber(decodeResult, data[1])
alt Value is empty
Note right of ResultFormatter: Early exit on empty value
else
ResultFormatter-->>H1Helper: formatted flight number
end
H1Helper-->>Client: return true with decodeResult
end
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
lib/utils/result_formatter.ts (2)
86-97: Good addition of input validation.The empty string check prevents processing invalid flight numbers, improving robustness. Consider adding similar validation for whitespace-only strings.
static flightNumber(decodeResult: DecodeResult, value: string) { - if(value.length === 0 ) { + if(value.length === 0 || !value.trim()) { return; } decodeResult.raw.flight_number = value;
250-261: Good addition of input validation.The empty string check prevents processing invalid temperatures, improving robustness. Consider adding similar validation for whitespace-only strings and invalid temperature formats.
static temperature(decodeResult: DecodeResult, value: string) { - if(value.length === 0 ) { + if(value.length === 0 || !value.trim() || !/^[MP]?\d+$/.test(value)) { return; } decodeResult.raw.outside_air_temperature = Number(value.replace("M", "-").replace("P", "+"));
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
lib/plugins/Label_4J_POS.test.ts(2 hunks)lib/plugins/Label_H1_FPN.test.ts(1 hunks)lib/plugins/Label_H1_FTX.test.ts(2 hunks)lib/plugins/Label_H1_INI.test.ts(2 hunks)lib/plugins/Label_H1_POS.test.ts(1 hunks)lib/utils/h1_helper.ts(3 hunks)lib/utils/result_formatter.ts(2 hunks)
🔇 Additional comments (7)
lib/plugins/Label_H1_FTX.test.ts (1)
22-30: LGTM! Test assertions updated correctly.The test assertions have been properly updated to include the Flight Number field as a formatted item, maintaining consistency with the new output structure.
Also applies to: 42-50
lib/plugins/Label_H1_INI.test.ts (1)
21-35: LGTM! Test assertions updated correctly.The test assertions have been properly updated to include the Flight Number field as a formatted item, maintaining consistency with the new output structure.
Also applies to: 47-61
lib/plugins/Label_4J_POS.test.ts (1)
35-53: LGTM! Test assertions updated correctly.The test assertions have been properly updated to include the Flight Number field as a formatted item, maintaining consistency with the new output structure.
Also applies to: 69-87
lib/utils/h1_helper.ts (2)
16-20: LGTM! Return value now matches the function's intent.The change ensures that a boolean value is always returned, making the function's behavior more explicit and consistent.
160-164: LGTM! Flight number handling is now consistent.The change uses
ResultFormatter.flightNumberto ensure consistent flight number formatting across the codebase.lib/plugins/Label_H1_FPN.test.ts (1)
237-260: LGTM! Test case updated to match new flight number handling.The test case correctly verifies that:
- Flight number is the first item in the formatted items.
- The total number of items is updated.
- The remaining items are properly shifted.
lib/plugins/Label_H1_POS.test.ts (1)
285-304: LGTM! Test case updated to match new flight number handling.The test case correctly verifies that:
- Flight number is the first item in the formatted items.
- The total number of items is updated.
- The remaining items are properly shifted.
also minor fix to always return boolean
Summary by CodeRabbit
New Features
Refactor