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

Add safe navigator to lines chomp #1366

Merged
merged 1 commit into from
Jun 18, 2021
Merged

Add safe navigator to lines chomp #1366

merged 1 commit into from
Jun 18, 2021

Conversation

victorhuangwq
Copy link
Contributor

Description

This change uses safe navigation operator to check for nil before calling chomp
https://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/

Motivation and Context

Addresses issue as found in #1360,
where chomp can be called on a nil object.

How Has This Been Tested?

Tested by running the segment of code and testing when an nil object is the result of lines[lines.length - 2]

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

Other issues / help required

If unsure, feel free to submit first and we'll help you along.

Copy link
Contributor

@xinyis991105 xinyis991105 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Tested a nil object with & (which was safe) and made sure that valid_json?(nil) returns false.

@victorhuangwq victorhuangwq merged commit 77675c2 into master Jun 18, 2021
@victorhuangwq victorhuangwq deleted the fix-chomp-for-nil branch June 18, 2021 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NoMethodError: undefined method `chomp' for nil in feedback viewer
2 participants