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/cask: Ensure that "verified" URLs with paths end with "/" #15125
rubocops/cask: Ensure that "verified" URLs with paths end with "/" #15125
Conversation
- These were being fixed manually[1], so let's make a RuboCop for any further occurrences since this is a good rule to enforce[2]. [1] - Homebrew/homebrew-cask#144179 (comment) [2] - Homebrew/homebrew-cask#80965 (comment)
I think one test case is missing: url "https://example.org/download",
verified: "example.org/download" In this case, the verified parameter should not end with a slash. |
Also url "https://example.org/",
verified: "example.org/" I think we already have a cop to ensure the slash for the actual URL in this case, but the verified parameter also needs the slash. |
🤔 So the following example does need the slash, but the above should not have one? Or did I misunderstand initially? url "https://example.com/download/foo-v1.2.0.dmg",
verified: "example.com/download" |
Yes, exactly. |
Handle good things like: ```ruby url "https://example.org/download", verified: "example.org/download" # This is fine. ``` And bad things like: ```ruby url "https://example.org/", verified: "example.org" # This should end with a slash. ```
d6aa751
to
21da074
Compare
Co-authored-by: Markus Reiter <me@reitermark.us>
Thanks for the thorough review @reitermarkus! |
4e9d30d
to
5cc39fb
Compare
- We see this a lot in real Casks.
5cc39fb
to
28f8cbe
Compare
Right, the real Casks report no offenses now I've fixed the handling for the syntax that I didn't see before. Tricksy Caskes. |
Good with me once |
# Skip if the URL and the verified value are the same. | ||
next if value_node.source == url_stanza.source.gsub(%r{^"https?://}, "\"") | ||
# Skip if the URL has two path components, eg: `https://github.com/google/fonts.git`. | ||
next if url_stanza.source.gsub(%r{^"https?://}, "\"").count("/") == 2 |
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.
@issyl0, this only fixes this particular case.
What if this isn't a GitHub URL with this specific format?
url "https://example.org/long/path/app-1.2.3.dmg",
verified: "example.org/long/path/app"
Granted I don't think we currently have any cask with such a format, but 2
is kinda arbitrary.
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.
I think we are overcomplicating the condition for this cop.
If verified
doesn't already end with a slash but the url
starts with "#{verified}/"
, a slash should be added.
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.
@reitermarkus That sounds good, could you open a PR for that?
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?