Skip to content
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

build(deps): bump rubocop from 0.84.0 to 0.85.0 in /Library/Homebrew #7677

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
**/vendor/bundle/ruby/*/gems/pry-*/
**/vendor/bundle/ruby/*/gems/rainbow-*/
**/vendor/bundle/ruby/*/gems/rdiscount-*/
**/vendor/bundle/ruby/*/gems/regexp_parser-*/
**/vendor/bundle/ruby/*/gems/ronn-*/
**/vendor/bundle/ruby/*/gems/rspec-*/
**/vendor/bundle/ruby/*/gems/rspec-core-*/
Expand Down
2 changes: 1 addition & 1 deletion Library/.rubocop_shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ AllCops:

# Use `<<~` for heredocs.
Layout/HeredocIndentation:
EnforcedStyle: squiggly
Enabled: true

# Not useful in casks and formulae.
Metrics/BlockLength:
Expand Down
4 changes: 3 additions & 1 deletion Library/Homebrew/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GEM
plist (3.5.0)
rainbow (3.0.0)
rdiscount (2.2.0.1)
regexp_parser (1.7.0)
rexml (3.2.4)
ronn (0.7.3)
hpricot (>= 0.8.2)
Expand All @@ -81,10 +82,11 @@ GEM
rspec-support (3.9.3)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
rubocop (0.84.0)
rubocop (0.85.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.0.3)
ruby-progressbar (~> 1.7)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def bad_sourceforge_url?
bad_url_format?(/sourceforge/,
[
%r{\Ahttps://sourceforge\.net/projects/[^/]+/files/latest/download\Z},
%r{\Ahttps://downloads\.sourceforge\.net/(?!(project|sourceforge)\/)},
%r{\Ahttps://downloads\.sourceforge\.net/(?!(project|sourceforge)/)},
])
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/blacklist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Cask
module Blacklist
def self.blacklisted_reason(name)
case name
when /^adobe\-(after|illustrator|indesign|photoshop|premiere)/
when /^adobe-(after|illustrator|indesign|photoshop|premiere)/
"Adobe casks were removed because they are too difficult to maintain."
when /^audacity$/
"Audacity was removed because it is too difficult to download programmatically."
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def self.nice_listing(cask_list)
end

def process_options(*args)
exclude_regex = /^\-\-#{Regexp.union(*Config::DEFAULT_DIRS.keys.map(&Regexp.public_method(:escape)))}=/
exclude_regex = /^--#{Regexp.union(*Config::DEFAULT_DIRS.keys.map(&Regexp.public_method(:escape)))}=/

non_options = []

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/cmd/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def process_arguments(*arguments)
next if self.class.options.nil?

self.class.options.each do |option_name, option_method|
option_type = case option_name.split(/(\ |\=)/).last
option_type = case option_name.split(/(\ |=)/).last
when "PATH"
Pathname
when /\w+(,\w+)+/
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def env
Shellwords.shellsplit(ENV.fetch("HOMEBREW_CASK_OPTS", ""))
.select { |arg| arg.include?("=") }
.map { |arg| arg.split("=", 2) }
.map { |(flag, value)| [flag.sub(/^\-\-/, ""), value] },
.map { |(flag, value)| [flag.sub(/^--/, ""), value] },
)
end

Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/cask/dsl/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class Version < ::String

DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join('|')})/.freeze

MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:\.([^.,:]+)(?:\.([^.,:]+))?)?/.freeze
MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:.([^.,:]+)(?:.([^.,:]+))?)?/.freeze

INVALID_CHARACTERS = /[^0-9a-zA-Z\.\,\:\-\_]/.freeze
INVALID_CHARACTERS = /[^0-9a-zA-Z.,:\-_]/.freeze

class << self
private
Expand Down Expand Up @@ -75,7 +75,7 @@ def unstable?
s = downcase.delete(".").gsub(/[^a-z\d]+/, "-")

return true if s.match?(/(\d+|\b)(alpha|beta|preview|rc|dev|canary|snapshot)(\d+|\b)/i)
return true if s.match?(/\A[a-z\d]+(\-\d+)*\-?(a|b|pre)(\d+|\b)/i)
return true if s.match?(/\A[a-z\d]+(-\d+)*-?(a|b|pre)(\d+|\b)/i)

false
end
Expand Down
12 changes: 6 additions & 6 deletions Library/Homebrew/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ def stale_formula?(scrub)
end
end

version ||= basename.to_s[/\A.*(?:\-\-.*?)*\-\-(.*?)#{Regexp.escape(extname)}\Z/, 1]
version ||= basename.to_s[/\A.*\-\-?(.*?)#{Regexp.escape(extname)}\Z/, 1]
version ||= basename.to_s[/\A.*(?:--.*?)*--(.*?)#{Regexp.escape(extname)}\Z/, 1]
version ||= basename.to_s[/\A.*--?(.*?)#{Regexp.escape(extname)}\Z/, 1]

return false unless version

version = Version.new(version)

return false unless formula_name = basename.to_s[/\A(.*?)(?:\-\-.*?)*\-\-?(?:#{Regexp.escape(version)})/, 1]
return false unless formula_name = basename.to_s[/\A(.*?)(?:--.*?)*--?(?:#{Regexp.escape(version)})/, 1]

formula = begin
Formulary.from_rack(HOMEBREW_CELLAR/formula_name)
rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
return false
end

resource_name = basename.to_s[/\A.*?\-\-(.*?)\-\-?(?:#{Regexp.escape(version)})/, 1]
resource_name = basename.to_s[/\A.*?--(.*?)--?(?:#{Regexp.escape(version)})/, 1]

if resource_name == "patch"
patch_hashes = formula.stable&.patches&.select(&:external?)&.map(&:resource)&.map(&:version)
Expand All @@ -92,15 +92,15 @@ def stale_formula?(scrub)
end

def stale_cask?(scrub)
return false unless name = basename.to_s[/\A(.*?)\-\-/, 1]
return false unless name = basename.to_s[/\A(.*?)--/, 1]

cask = begin
Cask::CaskLoader.load(name)
rescue Cask::CaskError
return false
end

return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}\-\-#{Regexp.escape(cask.version)}\b/)
return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}--#{Regexp.escape(cask.version)}\b/)

return true if scrub && !cask.versions.include?(cask.version)

Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def audit_specs
.map(&:to_i)

case (url = stable.url)
when /[\d\._-](alpha|beta|rc\d)/
when /[\d._-](alpha|beta|rc\d)/
matched = Regexp.last_match(1)
version_prefix = stable_version_string.sub(/\d+$/, "")
return if UNSTABLE_WHITELIST[formula.name] == version_prefix
Expand Down Expand Up @@ -803,7 +803,7 @@ def audit_text
end
bin_names.each do |name|
["system", "shell_output", "pipe_output"].each do |cmd|
if text.to_s.match?(/test do.*#{cmd}[\(\s]+['"]#{Regexp.escape(name)}[\s'"]/m)
if text.to_s.match?(/test do.*#{cmd}[(\s]+['"]#{Regexp.escape(name)}[\s'"]/m)
problem %Q(fully scope test #{cmd} calls, e.g. #{cmd} "\#{bin}/#{name}")
end
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def bottle_formula(f)
if any_go_deps
go_regex =
Version.formula_optionally_versioned_regex(:go, full: false)
ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/#{go_regex}/[\d\.]+/libexec}
ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/#{go_regex}/[\d.]+/libexec}
end

relocatable = true
Expand Down
18 changes: 9 additions & 9 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def use_correct_linux_tap(formula)
origin_branch = "#{homebrew_core_remote}/#{homebrew_core_branch}"
previous_branch = Utils.popen_read("git -C \"#{formula.tap.path}\" symbolic-ref -q --short HEAD").chomp
previous_branch = "master" if previous_branch.empty?
formula_path = formula.path.to_s[%r{(Formula\/.*)}, 1]
formula_path = formula.path.to_s[%r{(Formula/.*)}, 1]

if args.dry_run?
ohai "git remote add #{homebrew_core_remote} #{homebrew_core_url}"
Expand All @@ -89,7 +89,7 @@ def use_correct_linux_tap(formula)
return tap_full_name, origin_branch, previous_branch
else
formula.path.parent.cd do
unless Utils.popen_read("git remote -v").match?(%r{^homebrew.*Homebrew\/homebrew-core.*$})
unless Utils.popen_read("git remote -v").match?(%r{^homebrew.*Homebrew/homebrew-core.*$})
ohai "Adding #{homebrew_core_remote} remote"
safe_system "git", "remote", "add", homebrew_core_remote, homebrew_core_url
end
Expand Down Expand Up @@ -225,7 +225,7 @@ def bump_formula_pr

replacement_pairs += formula_spec.mirrors.map do |mirror|
[
/ +mirror \"#{Regexp.escape(mirror)}\"\n/m,
/ +mirror "#{Regexp.escape(mirror)}"\n/m,
"",
]
end
Expand Down Expand Up @@ -258,7 +258,7 @@ def bump_formula_pr

if new_mirrors
replacement_pairs << [
/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m,
/^( +)(url "#{Regexp.escape(new_url)}"\n)/m,
"\\1\\2\\1mirror \"#{new_mirrors.join("\"\n\\1mirror \"")}\"\n",
]
end
Expand All @@ -283,30 +283,30 @@ def bump_formula_pr
]
elsif new_mirrors
[
/^( +)(mirror \"#{Regexp.escape(new_mirrors.last)}\"\n)/m,
/^( +)(mirror "#{Regexp.escape(new_mirrors.last)}"\n)/m,
"\\1\\2\\1version \"#{forced_version}\"\n",
]
else
[
/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m,
/^( +)(url "#{Regexp.escape(new_url)}"\n)/m,
"\\1\\2\\1version \"#{forced_version}\"\n",
]
end
elsif requested_spec == :devel
replacement_pairs << [
/( devel do.+?version \")#{old_formula_version}(\"\n.+?end\n)/m,
/( devel do.+?version ")#{old_formula_version}("\n.+?end\n)/m,
"\\1#{forced_version}\\2",
]
end
elsif forced_version && forced_version == "0"
if requested_spec == :stable
replacement_pairs << [
/^ version \"[\w\.\-\+]+\"\n/m,
/^ version "[\w.\-+]+"\n/m,
"",
]
elsif requested_spec == :devel
replacement_pairs << [
/( devel do.+?)^ +version \"[^\n]+\"\n(.+?end\n)/m,
/( devel do.+?)^ +version "[^\n]+"\n(.+?end\n)/m,
"\\1\\2",
]
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/pull.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def pbcopy(text)

def check_bintray_mirror(name, url)
headers, = curl_output("--connect-timeout", "15", "--location", "--head", url)
status_code = headers.scan(%r{^HTTP\/.* (\d+)}).last.first
status_code = headers.scan(%r{^HTTP/.* (\d+)}).last.first
return if status_code.start_with?("2")

opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})."
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def cached_location
end

def basename
cached_location.basename.sub(/^[\da-f]{64}\-\-/, "")
cached_location.basename.sub(/^[\da-f]{64}--/, "")
end

private
Expand Down Expand Up @@ -390,7 +390,7 @@ def resolve_url_basename_time(url)
filenames = lines.map(&parse_content_disposition).compact

time =
lines.map { |line| line[/^Last\-Modified:\s*(.+)/i, 1] }
lines.map { |line| line[/^Last-Modified:\s*(.+)/i, 1] }
.compact
.map { |t| t.match?(/^\d+$/) ? Time.at(t.to_i) : Time.parse(t) }
.last
Expand Down Expand Up @@ -820,7 +820,7 @@ def github_last_commit

return unless status.success?

commit = output[/^ETag: \"(\h+)\"/, 1]
commit = output[/^ETag: "(\h+)"/, 1]
version.update_commit(commit) if commit
commit
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def extname(path = to_s)
return archive_ext if archive_ext

# Don't treat version numbers as extname.
return "" if basename.match?(/\b\d+\.\d+[^\.]*\Z/) && !basename.end_with?(".7z")
return "" if basename.match?(/\b\d+\.\d+[^.]*\Z/) && !basename.end_with?(".7z")

File.extname(basename)
end
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/extend/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def gsub!(before, after, audit_result = true)
# Looks for Makefile style variable definitions and replaces the
# value with "new_value", or removes the definition entirely.
def change_make_var!(flag, new_value)
return if gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=[ \t]*((?:.*\\\n)*.*)$/, "#{flag}=#{new_value}", false)
return if gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?+:!]?=[ \t]*((?:.*\\\n)*.*)$/, "#{flag}=#{new_value}", false)

errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
end
Expand All @@ -35,14 +35,14 @@ def change_make_var!(flag, new_value)
def remove_make_var!(flags)
Array(flags).each do |flag|
# Also remove trailing \n, if present.
unless gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=(?:.*\\\n)*.*$\n?/, "", false)
unless gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?+:!]?=(?:.*\\\n)*.*$\n?/, "", false)
errors << "expected to remove #{flag.inspect}"
end
end
end

# Finds the specified variable
def get_make_var(flag)
self[/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=[ \t]*((?:.*\\\n)*.*)$/, 1]
self[/^#{Regexp.escape(flag)}[ \t]*[\\?+:!]?=[ \t]*((?:.*\\\n)*.*)$/, 1]
end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class ParserError < StandardError
REGION_REGEX = /(?:[A-Z]{2}|\d{3})/.freeze # ISO 3166-1 or UN M.49
SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/.freeze # ISO 15924

LOCALE_REGEX = /\A((?:#{LANGUAGE_REGEX}|#{REGION_REGEX}|#{SCRIPT_REGEX})(?:\-|$)){1,3}\Z/.freeze
LOCALE_REGEX = /\A((?:#{LANGUAGE_REGEX}|#{REGION_REGEX}|#{SCRIPT_REGEX})(?:-|$)){1,3}\Z/.freeze

def self.parse(string)
string = string.to_s

raise ParserError, "'#{string}' cannot be parsed to a #{self}" unless string.match?(LOCALE_REGEX)

scan = proc do |regex|
string.scan(/(?:\-|^)(#{regex})(?:\-|$)/).flatten.first
string.scan(/(?:-|^)(#{regex})(?:-|$)/).flatten.first
end

language = scan.call(LANGUAGE_REGEX)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/rubocops/cask/homepage_matches_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def extract_url(stanza)
string = stanza.stanza_node.children[2]
return string.str_content if string.str_type?

string.to_s.gsub(%r{.*"([a-z0-9]+\:\/\/[^"]+)".*}m, '\1')
string.to_s.gsub(%r{.*"([a-z0-9]+://[^"]+)".*}m, '\1')
end

def url_match_homepage?(stanza)
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/rubocops/lines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)

find_instance_method_call(body_node, :build, :include?) do |method|
arg = parameters(method).first
next unless match = regex_match_group(arg, /^\-\-(.*)$/)
next unless match = regex_match_group(arg, /^--(.*)$/)

problem "Reference '#{match[1]}' without dashes"
end
Expand Down Expand Up @@ -403,7 +403,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)

path = parameters(method).first
next unless path.str_type?
next unless match = regex_match_group(path, /^[^\*{},]+$/)
next unless match = regex_match_group(path, /^[^*{},]+$/)

problem "Dir([\"#{string_content(path)}\"]) is unnecessary; just use \"#{match[0]}\""
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def describe_java
_, err, status = system_command("java", args: ["-version"], print_stderr: false)
return "N/A" unless status.success?

err[/java version "([\d\._]+)"/, 1] || "N/A"
err[/java version "([\d._]+)"/, 1] || "N/A"
end

def describe_git
Expand All @@ -100,7 +100,7 @@ def describe_git
def describe_curl
out, = system_command(curl_executable, args: ["--version"])

if /^curl (?<curl_version>[\d\.]+)/ =~ out
if /^curl (?<curl_version>[\d.]+)/ =~ out
"#{curl_version} => #{curl_executable}"
else
"N/A"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cmd/--cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
describe "brew --cache", :integration_test do
it "prints all cache files for a given Formula" do
expect { brew "--cache", testball }
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}\-\-testball\-}).to_stdout
.to output(%r{#{HOMEBREW_CACHE}/downloads/[\da-f]{64}--testball-}).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cmd/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def install
# and there will be the git requirement, but we cannot instantiate git
# formula since we only have testball1 formula.
expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
.to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout
.to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689}).to_stdout
.and output(/Cloning into/).to_stderr
.and be_a_success
expect(HOMEBREW_CELLAR/"testball1/HEAD-d5eb689/foo/test").not_to be_a_file
Expand Down
Loading