-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[changelog skip] Prefer String#strip to #chomp (#1085)
When manipulating the results of a shell result, it's common to want to remove the newline. ``` puts `ruby -v`.inspect # => "ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]\n" ``` This is commonly done by calling `chomp`. However there are some situations that are suspected to sometimes (but not always) contain two extra lines being tracked in heroku/hatchet#120 ## Chomp fails - https://dashboard.heroku.com/pipelines/ac057663-170b-4bdd-99d0-87560eb3a570/tests/1195 - https://dashboard.heroku.com/pipelines/ac057663-170b-4bdd-99d0-87560eb3a570/tests/1197 - Maybe there are multiple newlines in the original string. We can switch to strip instead of chomp. This PR replaces all uses of `chomp` that are intended to strip off trailing newlines with strip ```ruby puts "/hello\n\n".chomp.inspect # => "/hello\n" puts "/hello\n\n".strip.inspect # => "/hello" ``` It's not a perfect replacement, because `strip` also removes other whitespace characters and it modifies the beginning and end of the string. That being said, the ability to remove multiple newlines or any excess whitespace is the behavior we want.
- Loading branch information
Showing
9 changed files
with
30 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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