mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
rubocops/urls: stricter binary URL requirements.
Don't rely on x86_64 detection but instead whitelist the few projects that fun afoul of these regex.
This commit is contained in:
parent
2b3d7304e4
commit
9da6c9b521
@ -7,8 +7,21 @@ module RuboCop
|
|||||||
module FormulaAudit
|
module FormulaAudit
|
||||||
# This cop audits URLs and mirrors in Formulae.
|
# This cop audits URLs and mirrors in Formulae.
|
||||||
class Urls < FormulaCop
|
class Urls < FormulaCop
|
||||||
|
# These are parts of URLs that look like binaries but actually aren't.
|
||||||
|
NOT_A_BINARY_URL_PREFIX_WHITELIST = %w[
|
||||||
|
https://github.com/obihann/archey-osx/archive/
|
||||||
|
https://downloads.sourceforge.net/project/astyle/astyle/
|
||||||
|
https://downloads.sourceforge.net/project/bittwist/
|
||||||
|
https://downloads.sourceforge.net/project/launch4j/
|
||||||
|
https://osxbook.com/book/bonus/chapter8/core/download/gcore
|
||||||
|
https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/archive/
|
||||||
|
https://raw.githubusercontent.com/liyanage/macosx-shell-scripts/
|
||||||
|
https://github.com/sindresorhus/macos-wallpaper/archive/
|
||||||
|
].freeze
|
||||||
|
|
||||||
# These are formulae that, sadly, require an upstream binary to bootstrap.
|
# These are formulae that, sadly, require an upstream binary to bootstrap.
|
||||||
BINARY_FORMULA_URLS_WHITELIST = %w[
|
BINARY_BOOTSTRAP_FORMULA_URLS_WHITELIST = %w[
|
||||||
|
clozure-cl
|
||||||
crystal
|
crystal
|
||||||
fpc
|
fpc
|
||||||
ghc
|
ghc
|
||||||
@ -22,6 +35,10 @@ module RuboCop
|
|||||||
haskell-stack
|
haskell-stack
|
||||||
ldc
|
ldc
|
||||||
mlton
|
mlton
|
||||||
|
openjdk
|
||||||
|
openjdk@11
|
||||||
|
pypy
|
||||||
|
sbcl
|
||||||
rust
|
rust
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
@ -234,9 +251,11 @@ module RuboCop
|
|||||||
return if formula_tap != "homebrew-core"
|
return if formula_tap != "homebrew-core"
|
||||||
|
|
||||||
# Check for binary URLs
|
# Check for binary URLs
|
||||||
audit_urls(urls, /(darwin|macos|osx)/i) do |_, url|
|
audit_urls(urls, /(darwin|macos|osx)/i) do |match, url|
|
||||||
next if url !~ /x86_64/i && url !~ /amd64/i
|
next if @formula_name.include?(match.to_s.downcase)
|
||||||
next if BINARY_FORMULA_URLS_WHITELIST.include?(@formula_name)
|
next if url.match?(/.(patch|diff)(\?full_index=1)?$/)
|
||||||
|
next if NOT_A_BINARY_URL_PREFIX_WHITELIST.any? { |prefix| url.start_with?(prefix) }
|
||||||
|
next if BINARY_BOOTSTRAP_FORMULA_URLS_WHITELIST.include?(@formula_name)
|
||||||
|
|
||||||
problem "#{url} looks like a binary package, not a source archive; " \
|
problem "#{url} looks like a binary package, not a source archive; " \
|
||||||
"homebrew/core is source-only."
|
"homebrew/core is source-only."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user