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

Clean up some duplicated code #2715

Conversation

jacobherrington
Copy link
Contributor

Description

Looking through this file, I noticed some identical code that could be cleaned up.

This is only better subjectively, but I didn't see anything re: refactors in the contributing doc. If Puma tends to avoid style-oriented refactors like this one without a strong rationale, feel free to close this PR.

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added (or updated) appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

def wakeup!
return unless @wakeup

begin
Copy link
Member

Choose a reason for hiding this comment

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

Maybe remove begin and move the rescue to 'method level'?


private

def ensure_output_directory_exists(path)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe something like:

def ensure_output_directory_exists(path, io_name)

and pass 'STDOUT' or 'STDERR' to it, along with changing:

raise "Cannot redirect #{io_name} to #{path}"

@MSP-Greg
Copy link
Member

If Puma tends to avoid style-oriented refactors

Fine by me, not sure about others. Most older repos always have code that can be refactored. And, ruby/ruby is always refactoring...

@jacobherrington jacobherrington force-pushed the jacobherrington/remove-code-duplication branch from c47a836 to 25e210b Compare September 27, 2021 18:50
@jacobherrington
Copy link
Contributor Author

@MSP-Greg Thanks for the review, I pushed a new commit including your suggestions!

@nateberkopec nateberkopec merged commit 520dc92 into puma:master Sep 28, 2021
@nateberkopec
Copy link
Member

We're 100% ok with refactors here. I wouldn't even call this style-oriented, you're removing code, not just changing quotation marks and whitespace.

@jacobherrington jacobherrington deleted the jacobherrington/remove-code-duplication branch September 28, 2021 16:30
JuanitoFatas pushed a commit to JuanitoFatas/puma that referenced this pull request Sep 9, 2022
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.

None yet

3 participants