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
cask/audit: allow dots in version and check unversioned cask #16882
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -410,17 +410,48 @@ | |||||
add_error "cask token underscores should be replaced by hyphens" if cask.token.include? "_" | ||||||
add_error "cask token should not contain double hyphens" if cask.token.include? "--" | ||||||
|
||||||
if cask.token.match?(/[^@a-z0-9-]/) | ||||||
add_error "cask token should only contain lowercase alphanumeric characters, hyphens and @" | ||||||
end | ||||||
|
||||||
if cask.token.start_with?("-", "@") || cask.token.end_with?("-", "@") | ||||||
add_error "cask token should not have leading or trailing hyphens and/or @" | ||||||
end | ||||||
|
||||||
add_error "cask token @ unrelated to versioning should be replaced by -at-" if cask.token.count("@") > 1 | ||||||
add_error "cask token should not contain a hyphen followed by @" if cask.token.include? "-@" | ||||||
add_error "cask token should not contain @ followed by a hyphen" if cask.token.include? "@-" | ||||||
unversioned_token, _, version_designation = cask.token.rpartition("@") | ||||||
if unversioned_token.empty? | ||||||
match_data = /-(?<designation>alpha|beta|rc|release-candidate)$/.match(cask.token) | ||||||
if match_data && cask.tap&.official? && cask.tap != "homebrew/cask-versions" | ||||||
add_error "cask token should use @ before version designation '#{match_data[:designation]}'" | ||||||
end | ||||||
unversioned_token = cask.token | ||||||
version_designation = "" | ||||||
end | ||||||
|
||||||
add_error "unversioned cask token @ should be replaced by -at-" if unversioned_token.include? "@" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I just realized that "unversioned cask" was poor phrasing given its existing usage for unversioned URLs ( |
||||||
|
||||||
if unversioned_token.match?(/[^a-z0-9-]/) | ||||||
add_error "unversioned cask token should only contain lowercase alphanumeric characters and hyphens" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
end | ||||||
|
||||||
return if version_designation.empty? | ||||||
|
||||||
add_error "unversioned cask token should not have trailing hyphens" if unversioned_token.end_with?("-") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if version_designation.match?(/[^.a-z0-9-]/) | ||||||
add_error "cask token version designation should only contain " \ | ||||||
"lowercase alphanumeric characters, hyphens and '.'" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
end | ||||||
|
||||||
if version_designation.start_with?("-", ".") || version_designation.end_with?(".") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
add_error "cask token version designation should not have leading or trailing hyphens and/or '.'" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
end | ||||||
|
||||||
return unless cask.tap&.official? | ||||||
return if cask.tap&.audit_exception(:versioned_no_unversioned_allowlist, cask.token) | ||||||
|
||||||
unversioned_full_token = "#{cask.tap}/#{unversioned_token}" | ||||||
begin | ||||||
CaskLoader.load(unversioned_full_token) | ||||||
rescue CaskUnavailableError | ||||||
add_error "versioned cask but no #{unversioned_full_token} cask exists" | ||||||
end | ||||||
end | ||||||
|
||||||
sig { void } | ||||||
|
@@ -431,11 +462,6 @@ | |||||
|
||||||
add_error "cask token contains .app" if token.end_with? ".app" | ||||||
|
||||||
match_data = /-(?<designation>alpha|beta|rc|release-candidate)$/.match(cask.token) | ||||||
if match_data && cask.tap&.official? && cask.tap != "homebrew/cask-versions" | ||||||
add_error "cask token contains version designation '#{match_data[:designation]}'" | ||||||
end | ||||||
|
||||||
add_error("cask token mentions launcher", strict_only: true) if token.end_with? "launcher" | ||||||
|
||||||
add_error("cask token mentions desktop", strict_only: true) if token.end_with? "desktop" | ||||||
|
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.
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 was wondering if we should only apply to
homebrew/cask
given audit failures in fonts. From original location of check (which I'll probably move code back to later), I'm guessing we either don't apply that audit or there were no new fonts with-beta|alpha
.As I recall, we have automation there that picks those names?
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.
We should definitely fix the automation, but maybe this should only apply to
brew audit --new
for now?