Fix brew style
This commit is contained in:
parent
a80dd751a1
commit
fb4d08a49a
@ -45,8 +45,9 @@ SimpleCov.start do
|
|||||||
else
|
else
|
||||||
command_name "#{command_name} (#{$PROCESS_ID})"
|
command_name "#{command_name} (#{$PROCESS_ID})"
|
||||||
|
|
||||||
|
excludes = ["test", "vendor"]
|
||||||
subdirs = Dir.chdir(SimpleCov.root) { Dir.glob("*") }
|
subdirs = Dir.chdir(SimpleCov.root) { Dir.glob("*") }
|
||||||
.reject { |d| d.end_with?(".rb") || ["test", "vendor"].include?(d) }
|
.reject { |d| d.end_with?(".rb") || excludes.include?(d) }
|
||||||
.map { |d| "#{d}/**/*.rb" }.join(",")
|
.map { |d| "#{d}/**/*.rb" }.join(",")
|
||||||
|
|
||||||
# Not using this during integration tests makes the tests 4x times faster
|
# Not using this during integration tests makes the tests 4x times faster
|
||||||
|
|||||||
@ -85,9 +85,10 @@ module Cask
|
|||||||
|
|
||||||
# :launchctl must come before :quit/:signal for cases where app would instantly re-launch
|
# :launchctl must come before :quit/:signal for cases where app would instantly re-launch
|
||||||
def uninstall_launchctl(*services, command: nil, **_)
|
def uninstall_launchctl(*services, command: nil, **_)
|
||||||
|
booleans = [false, true]
|
||||||
services.each do |service|
|
services.each do |service|
|
||||||
ohai "Removing launchctl service #{service}"
|
ohai "Removing launchctl service #{service}"
|
||||||
[false, true].each do |with_sudo|
|
booleans.each do |with_sudo|
|
||||||
plist_status = command.run(
|
plist_status = command.run(
|
||||||
"/bin/launchctl",
|
"/bin/launchctl",
|
||||||
args: ["list", service],
|
args: ["list", service],
|
||||||
|
|||||||
@ -204,7 +204,8 @@ module Cask
|
|||||||
end
|
end
|
||||||
add_error "at least one name stanza is required" if cask.name.empty?
|
add_error "at least one name stanza is required" if cask.name.empty?
|
||||||
# TODO: specific DSL knowledge should not be spread around in various files like this
|
# TODO: specific DSL knowledge should not be spread around in various files like this
|
||||||
installable_artifacts = cask.artifacts.reject { |k| [:uninstall, :zap].include?(k) }
|
rejected_artifacts = [:uninstall, :zap]
|
||||||
|
installable_artifacts = cask.artifacts.reject { |k| rejected_artifacts.include?(k) }
|
||||||
add_error "at least one activatable artifact stanza is required" if installable_artifacts.empty?
|
add_error "at least one activatable artifact stanza is required" if installable_artifacts.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -893,8 +893,9 @@ module Homebrew
|
|||||||
|
|
||||||
bin_names += dir.children.map(&:basename).map(&:to_s)
|
bin_names += dir.children.map(&:basename).map(&:to_s)
|
||||||
end
|
end
|
||||||
|
shell_commands = ["system", "shell_output", "pipe_output"]
|
||||||
bin_names.each do |name|
|
bin_names.each do |name|
|
||||||
["system", "shell_output", "pipe_output"].each do |cmd|
|
shell_commands.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}")
|
problem %Q(fully scope test #{cmd} calls, e.g. #{cmd} "\#{bin}/#{name}")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -453,13 +453,14 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
any_cellars = ["any", "any_skip_relocation"]
|
||||||
bottles_hash.each do |formula_name, bottle_hash|
|
bottles_hash.each do |formula_name, bottle_hash|
|
||||||
ohai formula_name
|
ohai formula_name
|
||||||
|
|
||||||
bottle = BottleSpecification.new
|
bottle = BottleSpecification.new
|
||||||
bottle.root_url bottle_hash["bottle"]["root_url"]
|
bottle.root_url bottle_hash["bottle"]["root_url"]
|
||||||
cellar = bottle_hash["bottle"]["cellar"]
|
cellar = bottle_hash["bottle"]["cellar"]
|
||||||
cellar = cellar.to_sym if ["any", "any_skip_relocation"].include?(cellar)
|
cellar = cellar.to_sym if any_cellars.include?(cellar)
|
||||||
bottle.cellar cellar
|
bottle.cellar cellar
|
||||||
bottle.prefix bottle_hash["bottle"]["prefix"]
|
bottle.prefix bottle_hash["bottle"]["prefix"]
|
||||||
bottle.rebuild bottle_hash["bottle"]["rebuild"]
|
bottle.rebuild bottle_hash["bottle"]["rebuild"]
|
||||||
@ -478,14 +479,14 @@ module Homebrew
|
|||||||
update_or_add = "update"
|
update_or_add = "update"
|
||||||
if args.keep_old?
|
if args.keep_old?
|
||||||
mismatches = []
|
mismatches = []
|
||||||
|
valid_keys = %w[root_url prefix cellar rebuild sha1 sha256]
|
||||||
bottle_block_contents = s.inreplace_string[/ bottle do(.+?)end\n/m, 1]
|
bottle_block_contents = s.inreplace_string[/ bottle do(.+?)end\n/m, 1]
|
||||||
bottle_block_contents.lines.each do |line|
|
bottle_block_contents.lines.each do |line|
|
||||||
line = line.strip
|
line = line.strip
|
||||||
next if line.empty?
|
next if line.empty?
|
||||||
|
|
||||||
key, old_value_original, _, tag = line.split " ", 4
|
key, old_value_original, _, tag = line.split " ", 4
|
||||||
valid_key = %w[root_url prefix cellar rebuild sha1 sha256].include? key
|
next unless valid_keys.include?(key)
|
||||||
next unless valid_key
|
|
||||||
|
|
||||||
old_value = old_value_original.to_s.delete "'\""
|
old_value = old_value_original.to_s.delete "'\""
|
||||||
old_value = old_value.to_s.delete ":" if key != "root_url"
|
old_value = old_value.to_s.delete ":" if key != "root_url"
|
||||||
|
|||||||
@ -306,6 +306,11 @@ module Homebrew
|
|||||||
method_name
|
method_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
CUSTOM_IMPLEMENTATIONS = %w[
|
||||||
|
HOMEBREW_MAKE_JOBS
|
||||||
|
HOMEBREW_CASK_OPTS
|
||||||
|
].freeze
|
||||||
|
|
||||||
ENVS.each do |env, hash|
|
ENVS.each do |env, hash|
|
||||||
method_name = env_method_name(env, hash)
|
method_name = env_method_name(env, hash)
|
||||||
env = env.to_s
|
env = env.to_s
|
||||||
@ -316,7 +321,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
elsif hash[:default].present?
|
elsif hash[:default].present?
|
||||||
# Needs a custom implementation.
|
# Needs a custom implementation.
|
||||||
next if ["HOMEBREW_MAKE_JOBS", "HOMEBREW_CASK_OPTS"].include?(env)
|
next if CUSTOM_IMPLEMENTATIONS.include?(env)
|
||||||
|
|
||||||
define_method(method_name) do
|
define_method(method_name) do
|
||||||
ENV[env].presence || hash.fetch(:default).to_s
|
ENV[env].presence || hash.fetch(:default).to_s
|
||||||
|
|||||||
@ -154,7 +154,9 @@ module FormulaCellarChecks
|
|||||||
# Emacs itself can do what it wants
|
# Emacs itself can do what it wants
|
||||||
return if name == "emacs"
|
return if name == "emacs"
|
||||||
|
|
||||||
elisps = (share/"emacs/site-lisp").children.select { |file| %w[.el .elc].include? file.extname }
|
elisps = (share/"emacs/site-lisp").children.select do |file|
|
||||||
|
Keg::ELISP_EXTENSIONS.include? file.extname
|
||||||
|
end
|
||||||
return if elisps.empty?
|
return if elisps.empty?
|
||||||
|
|
||||||
<<~EOS
|
<<~EOS
|
||||||
|
|||||||
@ -122,6 +122,10 @@ class Keg
|
|||||||
mime-info pixmaps sounds postgresql
|
mime-info pixmaps sounds postgresql
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
|
ELISP_EXTENSIONS = %w[.el .elc].freeze
|
||||||
|
PYC_EXTENSIONS = %w[.pyc .pyo].freeze
|
||||||
|
LIBTOOL_EXTENSIONS = %w[.la .lai].freeze
|
||||||
|
|
||||||
# Given an array of kegs, this method will try to find some other kegs
|
# Given an array of kegs, this method will try to find some other kegs
|
||||||
# that depend on them. If it does, it returns:
|
# that depend on them. If it does, it returns:
|
||||||
#
|
#
|
||||||
@ -423,7 +427,7 @@ class Keg
|
|||||||
def elisp_installed?
|
def elisp_installed?
|
||||||
return false unless (path/"share/emacs/site-lisp"/name).exist?
|
return false unless (path/"share/emacs/site-lisp"/name).exist?
|
||||||
|
|
||||||
(path/"share/emacs/site-lisp"/name).children.any? { |f| %w[.el .elc].include? f.extname }
|
(path/"share/emacs/site-lisp"/name).children.any? { |f| ELISP_EXTENSIONS.include? f.extname }
|
||||||
end
|
end
|
||||||
|
|
||||||
def version
|
def version
|
||||||
@ -559,7 +563,7 @@ class Keg
|
|||||||
end
|
end
|
||||||
|
|
||||||
def delete_pyc_files!
|
def delete_pyc_files!
|
||||||
find { |pn| pn.delete if %w[.pyc .pyo].include?(pn.extname) }
|
find { |pn| pn.delete if PYC_EXTENSIONS.include?(pn.extname) }
|
||||||
find { |pn| FileUtils.rm_rf pn if pn.basename.to_s == "__pycache__" }
|
find { |pn| FileUtils.rm_rf pn if pn.basename.to_s == "__pycache__" }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -652,7 +656,7 @@ class Keg
|
|||||||
# Don't link pyc or pyo files because Python overwrites these
|
# Don't link pyc or pyo files because Python overwrites these
|
||||||
# cached object files and next time brew wants to link, the
|
# cached object files and next time brew wants to link, the
|
||||||
# file is in the way.
|
# file is in the way.
|
||||||
Find.prune if %w[.pyc .pyo].include?(src.extname) && src.to_s.include?("/site-packages/")
|
Find.prune if PYC_EXTENSIONS.include?(src.extname) && src.to_s.include?("/site-packages/")
|
||||||
|
|
||||||
case yield src.relative_path_from(root)
|
case yield src.relative_path_from(root)
|
||||||
when :skip_file, nil
|
when :skip_file, nil
|
||||||
|
|||||||
@ -170,7 +170,7 @@ class Keg
|
|||||||
libtool_files = []
|
libtool_files = []
|
||||||
|
|
||||||
path.find do |pn|
|
path.find do |pn|
|
||||||
next if pn.symlink? || pn.directory? || ![".la", ".lai"].include?(pn.extname)
|
next if pn.symlink? || pn.directory? || !Keg::LIBTOOL_EXTENSIONS.include?(pn.extname)
|
||||||
|
|
||||||
libtool_files << pn
|
libtool_files << pn
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,6 +37,8 @@ module RuboCop
|
|||||||
|
|
||||||
# This cop audits deprecate! reason
|
# This cop audits deprecate! reason
|
||||||
class DeprecateDisableReason < FormulaCop
|
class DeprecateDisableReason < FormulaCop
|
||||||
|
PUNCTUATION_MARKS = %w[. ! ?].freeze
|
||||||
|
|
||||||
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
||||||
[:deprecate!, :disable!].each do |method|
|
[:deprecate!, :disable!].each do |method|
|
||||||
node = find_node_method_by_name(body_node, method)
|
node = find_node_method_by_name(body_node, method)
|
||||||
@ -53,7 +55,7 @@ module RuboCop
|
|||||||
|
|
||||||
problem "Do not start the reason with `it`" if reason_string.start_with?("it ")
|
problem "Do not start the reason with `it`" if reason_string.start_with?("it ")
|
||||||
|
|
||||||
problem "Do not end the reason with a punctuation mark" if %w[. ! ?].include?(reason_string[-1])
|
problem "Do not end the reason with a punctuation mark" if PUNCTUATION_MARKS.include?(reason_string[-1])
|
||||||
end
|
end
|
||||||
|
|
||||||
next if reason_found
|
next if reason_found
|
||||||
@ -73,7 +75,7 @@ module RuboCop
|
|||||||
lambda do |corrector|
|
lambda do |corrector|
|
||||||
reason = string_content(node)
|
reason = string_content(node)
|
||||||
reason = reason[3..] if reason.start_with?("it ")
|
reason = reason[3..] if reason.start_with?("it ")
|
||||||
reason.chop! if %w[. ! ?].include?(reason[-1])
|
reason.chop! if PUNCTUATION_MARKS.include?(reason[-1])
|
||||||
corrector.replace(node.source_range, "\"#{reason}\"")
|
corrector.replace(node.source_range, "\"#{reason}\"")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -178,6 +178,7 @@ module Homebrew
|
|||||||
json = json_result!(result)
|
json = json_result!(result)
|
||||||
|
|
||||||
# Convert to same format as RuboCop offenses.
|
# Convert to same format as RuboCop offenses.
|
||||||
|
severity_hash = { "style" => "refactor", "info" => "convention" }
|
||||||
json.group_by { |v| v["file"] }
|
json.group_by { |v| v["file"] }
|
||||||
.map do |k, v|
|
.map do |k, v|
|
||||||
{
|
{
|
||||||
@ -188,7 +189,7 @@ module Homebrew
|
|||||||
o["cop_name"] = "SC#{o.delete("code")}"
|
o["cop_name"] = "SC#{o.delete("code")}"
|
||||||
|
|
||||||
level = o.delete("level")
|
level = o.delete("level")
|
||||||
o["severity"] = { "style" => "refactor", "info" => "convention" }.fetch(level, level)
|
o["severity"] = severity_hash.fetch(level, level)
|
||||||
|
|
||||||
line = o.delete("line")
|
line = o.delete("line")
|
||||||
column = o.delete("column")
|
column = o.delete("column")
|
||||||
|
|||||||
@ -433,9 +433,10 @@ module GitHub
|
|||||||
result = open_graphql(query, scopes: ["user:email"])
|
result = open_graphql(query, scopes: ["user:email"])
|
||||||
reviews = result["repository"]["pullRequest"]["reviews"]["nodes"]
|
reviews = result["repository"]["pullRequest"]["reviews"]["nodes"]
|
||||||
|
|
||||||
|
valid_associations = %w[MEMBER OWNER]
|
||||||
reviews.map do |r|
|
reviews.map do |r|
|
||||||
next if commit.present? && commit != r["commit"]["oid"]
|
next if commit.present? && commit != r["commit"]["oid"]
|
||||||
next unless %w[MEMBER OWNER].include? r["authorAssociation"]
|
next unless valid_associations.include? r["authorAssociation"]
|
||||||
|
|
||||||
email = if r["author"]["email"].blank?
|
email = if r["author"]["email"].blank?
|
||||||
"#{r["author"]["databaseId"]}+#{r["author"]["login"]}@users.noreply.github.com"
|
"#{r["author"]["databaseId"]}+#{r["author"]["login"]}@users.noreply.github.com"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user