Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove redundant early return in livecheck skip_conditions #17591

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Jun 29, 2024

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

This is currently blocking #17586, #17586, and #17587:

$ brew typecheck
livecheck/skip_conditions.rb:233: This code is unreachable https://srb.help/7006
     233 |        return {} unless checks
                  ^^^^^^^^^
    livecheck/skip_conditions.rb:233: This condition was always `truthy` (`[Symbol, Symbol, Symbol, Symbol, Symbol]`)
     233 |        return {} unless checks
                                   ^^^^^^
  Got `[Symbol, Symbol, Symbol, Symbol, Symbol] (5-tuple)` originating from:
    livecheck/skip_conditions.rb:188:
     188 |      FORMULA_CHECKS = [
                ^^^^^^^^^^^^^^
    livecheck/skip_conditions.rb:233: This condition was always `truthy` (`[Symbol, Symbol, Symbol, Symbol, Symbol, Symbol]`)
     233 |        return {} unless checks
                                   ^^^^^^
  Got `[Symbol, Symbol, Symbol, Symbol, Symbol, Symbol] (6-tuple)` originating from:
    livecheck/skip_conditions.rb:197:
     197 |      CASK_CHECKS = [
                ^^^^^^^^^^^
    livecheck/skip_conditions.rb:233: This condition was always `truthy` (`[Symbol]`)
     233 |        return {} unless checks
                                   ^^^^^^
  Got `[Symbol] (1-tuple)` originating from:
    livecheck/skip_conditions.rb:207:
     207 |      RESOURCE_CHECKS = [
                ^^^^^^^^^^^^^^^

As far as I can tell, brew typecheck is correct that check can never be falsey at this point. I believe that only Formula, Cask::Cask, and Resource implement #livecheckable?, so I don't think there's a way for package_or_resource to not match one of the three cases.

If we are worried, we can also change the next line to be checks&.each do |method_name|.

@Rylan12 Rylan12 merged commit f5828e3 into master Jun 29, 2024
25 checks passed
@Rylan12 Rylan12 deleted the typecheck-fix branch June 29, 2024 22:51
@MikeMcQuaid
Copy link
Member

Thanks @Rylan12!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants