-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix bug when portInfo was null #168
Conversation
@miq-bot add_label bug |
@miq-bot assign @agrare |
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.
Thanks @felipedf , just minor changes here
@@ -90,7 +90,7 @@ def parse_child_devices(device, all_devices) | |||
|
|||
def parse_ports(port) | |||
port_info = port["portInfo"] | |||
physical_ports = port_info["physicalPorts"] | |||
physical_ports = port_info&.try(:[], 'physicalPorts') |
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.
I believe that a try
call here is enough, you can remove the &
.
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.
That's correct, or you can use port_info&.dig('physicalPorts')
...up to you but I've never liked the way .try
looks with a hash dereference
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.
Cool, .dig seems cleaner to me
@@ -90,7 +90,7 @@ def parse_child_devices(device, all_devices) | |||
|
|||
def parse_ports(port) | |||
port_info = port["portInfo"] | |||
physical_ports = port_info["physicalPorts"] | |||
physical_ports = port_info&.try(:[], 'physicalPorts') | |||
physical_ports&.map do |physical_port| |
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.
To keep the pattern, could you replace the &
with a try
call?
This pull request is not mergeable. Please rebase and repush. |
@felipedf looks good but can you rebase on master and resolve the conflict? |
Checked commit felipedf@35fda32 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
The refresh was crashing when a port didn't contain a "portInfo" field