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

Check that a single uninstall_* and zap stanza is defined #3389

Merged
merged 6 commits into from Nov 3, 2017

Conversation

Projects
None yet
3 participants
@amyspark
Member

amyspark commented Oct 28, 2017

  • 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.
  • Have you successfully run brew tests with your changes locally?

This pull requests fixes Homebrew/homebrew-cask#23885 by checking that only a single uninstall and zap stanza is present in the Cask. I've also extended it to check the *preflight and *postflight stanzas as well.
I don't yet know how to write Ruby tests, so I've not attached any. Tests have been included for all stanzas.

Please review, and thanks for your comments!

@amyspark

This comment has been minimized.

Show comment
Hide comment
@amyspark
Member

amyspark commented Oct 30, 2017

@reitermarkus

Some small changes are needed, but nothing major. Also, please add some tests, thanks!

Show outdated Hide outdated Library/Homebrew/cask/lib/hbc/audit.rb Outdated
Show outdated Hide outdated Library/Homebrew/cask/lib/hbc/audit.rb Outdated
@amyspark

This comment has been minimized.

Show comment
Hide comment
@amyspark

amyspark Oct 30, 2017

Member

I've taken the opportunity to include the same checks for the preflight and postflight stanzas.
With these changes, the only Cask that fails my tests is totalspaces. I'd need input from a Homebrew-Cask maintainer here.

Member

amyspark commented Oct 30, 2017

I've taken the opportunity to include the same checks for the preflight and postflight stanzas.
With these changes, the only Cask that fails my tests is totalspaces. I'd need input from a Homebrew-Cask maintainer here.

@commitay

This comment has been minimized.

Show comment
Hide comment
@commitay

commitay Oct 31, 2017

Member

With these changes, the only Cask that fails my tests is totalspaces.

Homebrew/homebrew-cask#40180

Member

commitay commented Oct 31, 2017

With these changes, the only Cask that fails my tests is totalspaces.

Homebrew/homebrew-cask#40180

@amyspark

This comment has been minimized.

Show comment
Hide comment
@amyspark

amyspark Nov 2, 2017

Member

@reitermarkus, I've pushed a commit to fix the ifs, but now brew style complains about two lines:

amalia@Sakura:/usr/local/Homebrew$ brew style --fix
Inspecting 671 files
.............................................................................................................C.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

Library/Homebrew/cask/lib/hbc/audit.rb:60:7: C: Use a guard clause instead of wrapping the code inside a conditional expression.
      if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:postflight) } > 1
      ^^
Library/Homebrew/cask/lib/hbc/audit.rb:80:7: C: Use a guard clause instead of wrapping the code inside a conditional expression.
      if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Zap) } > 1
      ^^

671 files inspected, 2 offenses detected
Member

amyspark commented Nov 2, 2017

@reitermarkus, I've pushed a commit to fix the ifs, but now brew style complains about two lines:

amalia@Sakura:/usr/local/Homebrew$ brew style --fix
Inspecting 671 files
.............................................................................................................C.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

Library/Homebrew/cask/lib/hbc/audit.rb:60:7: C: Use a guard clause instead of wrapping the code inside a conditional expression.
      if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:postflight) } > 1
      ^^
Library/Homebrew/cask/lib/hbc/audit.rb:80:7: C: Use a guard clause instead of wrapping the code inside a conditional expression.
      if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Zap) } > 1
      ^^

671 files inspected, 2 offenses detected
@reitermarkus

This comment has been minimized.

Show comment
Hide comment
@reitermarkus

reitermarkus Nov 2, 2017

Member

Use return unless for the last statement.

Member

reitermarkus commented Nov 2, 2017

Use return unless for the last statement.

@amyspark

This comment has been minimized.

Show comment
Hide comment
@amyspark

amyspark Nov 2, 2017

Member

@reitermarkus, thanks for your comments! I think this is ready now.

Member

amyspark commented Nov 2, 2017

@reitermarkus, thanks for your comments! I think this is ready now.

@reitermarkus reitermarkus merged commit 4eeac6f into Homebrew:master Nov 3, 2017

3 checks passed

codecov/patch 100% of diff hit (target 68.39%)
Details
codecov/project 69.19% (+0.8%) compared to 7caca57
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@reitermarkus

This comment has been minimized.

Show comment
Hide comment
@reitermarkus

reitermarkus Nov 3, 2017

Member

Great work, @amyspark!

Member

reitermarkus commented Nov 3, 2017

Great work, @amyspark!

@amyspark amyspark deleted the amyspark:hacktoberfest-single-zap branch Nov 3, 2017

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.