-
Notifications
You must be signed in to change notification settings - Fork 111
core:services:cabel_guy: Reduce code complexity of get_interfaces
method
#3499
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
Draft
joaomariolago
wants to merge
2
commits into
bluerobotics:master
Choose a base branch
from
joaomariolago:reduce-cable-guy-method-complexity
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
core:services:cabel_guy: Reduce code complexity of get_interfaces
method
#3499
joaomariolago
wants to merge
2
commits into
bluerobotics:master
from
joaomariolago:reduce-cable-guy-method-complexity
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Make sure that when `_execute_route` is called it keeps the DHCP requisition IP marker `0.0.0.0` `Mode.Client` alive
* Split `get_interfaces` method to reduce code complexity
Reviewer's GuideRefactors get_interfaces and related methods by extracting address processing and interface building into private helpers, adds an include_dhcp_markers option across interface retrieval methods, and updates calls to utilize the new parameters. Sequence diagram for interface retrieval with DHCP marker optionsequenceDiagram
participant Caller
participant Manager
participant NetworkInterface
Caller->>Manager: get_ethernet_interfaces(include_dhcp_markers=True)
Manager->>Manager: get_interfaces(filter_wifi=True, include_dhcp_markers=True)
Manager->>Manager: _process_interface_addresses(...)
Manager->>Manager: _add_dhcp_markers_if_needed(..., include_dhcp_markers=True)
Manager->>Manager: _build_network_interface(...)
Manager-->>Caller: List[NetworkInterface] (with DHCP marker if needed)
Class diagram for refactored interface retrieval methodsclassDiagram
class Manager {
+get_interfaces(filter_wifi: bool = False, include_dhcp_markers: bool = False) List[NetworkInterface]
+get_ethernet_interfaces(include_dhcp_markers: bool = False) List[NetworkInterface]
+get_interface_by_name(name: str, include_dhcp_markers: bool = False) NetworkInterface
-_process_interface_addresses(interface: str, addresses: List[Any]) List[InterfaceAddress]
-_add_dhcp_markers_if_needed(interface: str, valid_addresses: List[InterfaceAddress], include_dhcp_markers: bool) List[InterfaceAddress]
-_determine_address_mode(interface: str, ip: str, is_static_ip: bool, valid_ip: bool) AddressMode
-_get_interface_priority_value(interface: str) Optional[int]
-_build_network_interface(interface: str, valid_addresses: List[InterfaceAddress], filter_wifi: bool) Optional[NetworkInterface]
}
class NetworkInterface {
+name: str
+addresses: List[InterfaceAddress]
+info: Any
+priority: Optional[int]
+routes: List[Route]
}
class InterfaceAddress {
+ip: str
+mode: AddressMode
}
class AddressMode {
<<enum>>
Server
BackupServer
Unmanaged
Client
}
Manager --> NetworkInterface
NetworkInterface --> InterfaceAddress
InterfaceAddress --> AddressMode
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #3479
Summary by Sourcery
Refactor and simplify the get_interfaces workflow by extracting address processing, DHCP marker handling, priority resolution, and network interface construction into dedicated helper methods, and add support for an optional include_dhcp_markers flag across relevant methods.
Enhancements: