- Notifications
You must be signed in to change notification settings - Fork 129
Fix build report issue with FTL devices#1809
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Summary of ChangesHello @a-maurice, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a bug in the build report generation script. Previously, the script would encounter an error if it failed to retrieve information for certain FTL devices. The implemented change adds a check to ensure that device data is valid before processing, thereby enhancing the script's stability and preventing unexpected failures during report generation. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request fixes a crash in the build report script that occurs when FTL devices are not found. The fix correctly adds a null check before accessing attributes of a device. My review includes suggestions to refactor the changed sections to improve efficiency and readability by using a single loop to process devices, avoiding repeated function calls and multiple iterations over the same data. This also makes the code more robust by using explicit equality checks instead of in for string comparison.
| ftl_devices=set(filter(lambdadevice: get_test_device(device)andget_test_device(device).get("type") in"ftl", config_value)) | ||
| simulators=set(filter(lambdadevice: get_test_device(device)andget_test_device(device).get("type") in"virtual", config_value)) |
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.
While the added check for get_test_device(device) correctly prevents a crash, this implementation can be improved for readability and efficiency.
- Repeated function calls:
get_test_device(device)is called twice in the lambda for each device, andconfig_valueis iterated over twice (once forftl_devices, once forsimulators). - Confusing string check: Using
in "ftl"orin "virtual"is confusing and less precise than==. It works here because the only possible values are"ftl"and"virtual", but it's brittle.
I suggest refactoring this to a single loop that categorizes devices. This is more efficient and readable.
| ftl_devices=set(filter(lambdadevice: get_test_device(device) andget_test_device(device).get("type") in"ftl", config_value)) | |
| simulators=set(filter(lambdadevice: get_test_device(device) andget_test_device(device).get("type") in"virtual", config_value)) | |
| ftl_devices=set() | |
| simulators=set() | |
| fordeviceinconfig_value: | |
| test_device=get_test_device(device) | |
| ifnottest_device: | |
| continue | |
| device_type=test_device.get("type") | |
| ifdevice_type=="ftl": | |
| ftl_devices.add(device) | |
| elifdevice_type=="virtual": | |
| simulators.add(device) |
| ftl_devices=set(filter(lambdadevice: get_test_device(device)andget_test_device(device).get("type") in"ftl", config_value)) | ||
| emulators=set(filter(lambdadevice: get_test_device(device)andget_test_device(device).get("type") in"virtual", config_value)) |
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.
Similar to the ios_device case, this logic can be refactored to be more efficient and readable by using a single loop. This avoids iterating over config_value multiple times and calling get_test_device repeatedly inside the lambdas. This change also replaces the confusing in "string" check with a clearer == comparison.
| ftl_devices=set(filter(lambdadevice: get_test_device(device) andget_test_device(device).get("type") in"ftl", config_value)) | |
| emulators=set(filter(lambdadevice: get_test_device(device) andget_test_device(device).get("type") in"virtual", config_value)) | |
| ftl_devices=set() | |
| emulators=set() | |
| fordeviceinconfig_value: | |
| test_device=get_test_device(device) | |
| ifnottest_device: | |
| continue | |
| device_type=test_device.get("type") | |
| ifdevice_type=="ftl": | |
| ftl_devices.add(device) | |
| elifdevice_type=="virtual": | |
| emulators.add(device) |
Description
Fix error in build report script when the FTL devices can't be found
Testing
https://github.com/firebase/firebase-cpp-sdk/actions/runs/20252064775
Type of Change
Place an
xthe applicable box:Notes
Release Notessection ofrelease_build_files/readme.md.