Skip to content
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

Merged
merged 1 commit into from
May 9, 2018
Merged

Conversation

felipedf
Copy link
Member

@felipedf felipedf commented May 4, 2018

The refresh was crashing when a port didn't contain a "portInfo" field

@felipedf
Copy link
Member Author

felipedf commented May 4, 2018

@miq-bot add_label bug

@miq-bot miq-bot added the bug label May 4, 2018
@felipedf
Copy link
Member Author

felipedf commented May 4, 2018

@miq-bot assign @agrare
@rodneyhbrown7

Copy link
Member

@douglasgabriel douglasgabriel left a 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')
Copy link
Member

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 &.

Copy link
Member

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

Copy link
Member Author

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|
Copy link
Member

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?

@miq-bot
Copy link
Member

miq-bot commented May 8, 2018

This pull request is not mergeable. Please rebase and repush.

@agrare
Copy link
Member

agrare commented May 9, 2018

@felipedf looks good but can you rebase on master and resolve the conflict?

@felipedf felipedf force-pushed the port_parser_bug branch from 779acac to 35fda32 Compare May 9, 2018 17:27
@miq-bot
Copy link
Member

miq-bot commented May 9, 2018

Checked commit felipedf@35fda32 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🏆

@agrare agrare removed the unmergeable label May 9, 2018
@agrare agrare merged commit 4d68098 into ManageIQ:master May 9, 2018
@agrare agrare added this to the Sprint 86 Ending May 21, 2018 milestone May 9, 2018
@felipedf felipedf deleted the port_parser_bug branch May 9, 2018 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants