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

Refactor commands to remove 'require "cmd/*"' #4286

Merged
merged 1 commit into from
Jun 7, 2018
Merged

Refactor commands to remove 'require "cmd/*"' #4286

merged 1 commit into from
Jun 7, 2018

Conversation

apjanke
Copy link
Contributor

@apjanke apjanke commented Jun 6, 2018

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example. No: no feature changes; only a refactor.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This is an attempt to refactor install, upgrade, and help to remove their use of require "cmd/*" imports.

Fixes #4059.

Does this style of refactoring look good to you folks? If so, I'll do the rest, except for search, which is handled in #4253.

@apjanke
Copy link
Contributor Author

apjanke commented Jun 6, 2018

BTW, the style failure is this:

$ brew style ./cmd/install.rb                                                                            ✘ 1 refactor-require-cmd ✭
Warning: unrecognized cop Rspec/ExpectActual found in .rubocop.yml
== cmd/install.rb ==
C:300: 23: Method parameter must be at least 3 characters long.

1 file inspected, 1 offense detected

Complaining about:

def install_formula(f)

Are we actually requiring longer argument names now? I seem to recall quite a few of these function(f) functions.

@MikeMcQuaid
Copy link
Member

Does this style of refactoring look good to you folks? If so, I'll do the rest, except for search, which is handled in #4253.

Yes, definitely, thanks and great work here!

Are we actually requiring longer argument names now?
Are we actually requiring longer argument names now? I seem to recall quite a few of these function(f) functions.

I think ideally, yeh. Make it formula. Thanks!

@apjanke
Copy link
Contributor Author

apjanke commented Jun 6, 2018

Cool.

I don't remember: do you accept PRs for style-only fixes? I could make a pass of style fixes after doing this refactor; there's a lot of files with style complaints right now.

@reitermarkus
Copy link
Member

I don't remember: do you accept PRs for style-only fixes? I could make a pass of style fixes after doing this refactor; there's a lot of files with style complaints right now.

Not sure what you mean here, brew style should always pass before merging a PR.

@reitermarkus
Copy link
Member

I think the problem is that brew style ./cmd/install.rb uses the Formula-specific style rules.

@apjanke
Copy link
Contributor Author

apjanke commented Jun 6, 2018

I think the problem is that brew style ./cmd/install.rb uses the Formula-specific style rules.

Oh, yep, that's what's going on. When you pass a file argument, it pulls in the "audit" rules, regardless of whether that file is a formula or something else.

No problem; I can just run plain brew style from now on. It's fast enough.

@apjanke apjanke changed the title Refactor install, upgrade, and help to remove 'require "cmd/*"' Refactor commands to remove 'require "cmd/*"' Jun 6, 2018
@apjanke
Copy link
Contributor Author

apjanke commented Jun 6, 2018

I've updated this PR to include other commands. Combined with #4253, this will cover all the commands that are importing "cmd/*". Then we need to refactor the tests, but I'll leave that for another PR.


def check_writable_install_location
raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? && !HOMEBREW_CELLAR.writable_real?
raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable_real? || HOMEBREW_PREFIX.to_s == "/usr/local"
Copy link
Member

Choose a reason for hiding this comment

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

Can you make both the above block ifs (and refactor the unless .. ||). I know not your code but nice to refactor this so it's not wider than the GitHub diff UI.

@MikeMcQuaid
Copy link
Member

I've updated this PR to include other commands. Combined with #4253, this will cover all the commands that are importing "cmd/*". Then we need to refactor the tests, but I'll leave that for another PR.

Nice! One nit but otherwise 👍 👏.

@MikeMcQuaid
Copy link
Member

Library/Homebrew/cmd/style.rb

Rebase needed for this.

@apjanke
Copy link
Contributor Author

apjanke commented Jun 7, 2018

Amended to rebase and refactor that nit out. (Had to modify the nit code a bit more to satisfy brew style.)

@MikeMcQuaid MikeMcQuaid merged commit 6a8194a into Homebrew:master Jun 7, 2018
@MikeMcQuaid
Copy link
Member

Thanks again @apjanke!

@lock lock bot added the outdated PR was locked due to age label Jul 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants