-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
rubocops/livecheck: Rework LivecheckUrlProvided #16932
rubocops/livecheck: Rework LivecheckUrlProvided #16932
Conversation
Can you think of an example when this would be the case? Do we have other methods that require a URL, or is the check really only there to avoid an empty |
In this particular context, I was referring to something [undesirable] like the following: livecheck do
regex(/^v?(\d+(?:\.\d+)+)$/i)
throttle 10
end livecheck do
strategy :page_match
throttle 10
end If we skipped the
The idea behind the Thinking about this, it may be better to rework the RuboCop to only require a Edit: I updated this to rework the RuboCop as described, as that should meet the same goals while requiring less maintenance when methods are added to the livecheck DSL. |
bb20aef
to
37a97f0
Compare
The existing `LivecheckUrlProvided` RuboCop requires a `url` for all `livecheck` blocks except those using `skip`, `formula`, or `cask`, as those only appear in a `livecheck` block with no other DSL methods. We now have a `throttle` method that can be used alongside other DSL methods (e.g., `url`, `regex`, `strategy`) or by itself. `brew style` currently fails when `throttle` is used by itself, so this reworks the conditions to allow this usage.
37a97f0
to
b3ab410
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine, thanks @samford!
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?The existing
LivecheckUrlProvided
RuboCop requires aurl
for alllivecheck
blocks except those usingskip
,formula
, orcask
, as those only appear in alivecheck
block with no other DSL methods.We now have a
throttle
method that can be used alongside other DSL methods (e.g.,url
,regex
,strategy
) or by itself.brew style
currently fails whenthrottle
is used by itself (e.g., Homebrew/homebrew-core#166501), so this updates the conditions to allow this usage.I'm currently doing this by specifically exemptinglivecheck
blocks that only include#throttle
(i.e., so we don't unexpectedly skip the check forlivecheck
blocks that use#throttle
alongside other methods). I'm not very versed with RuboCop, so there may be a better way of achieving the same goal.I've gone about this by reworking the
LivecheckUrlProvided
RuboCop to only require aurl
when alivecheck
block uses#regex
and/or#strategy
, as that information is intended for a specific URL. This allows us to get rid of the special-case conditions for#skip
,#formula
, and#cask
(and avoid adding additional conditions for#throttle
).