aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorMarkus Reiter2017-10-07 00:31:28 +0200
committerMarkus Reiter2017-10-08 16:10:37 +0200
commit175ca909ee1a5b57aa0cae2c879920511f311b14 (patch)
tree067464b4c08f4c16ca3439b533f06669a78c370c /Library/Homebrew/dev-cmd
parent91ab116ace7f4f97d3440190463c93be9ec6d675 (diff)
downloadbrew-175ca909ee1a5b57aa0cae2c879920511f311b14.tar.bz2
Clean up code style and remove `.rubocop_todo.yml`.
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/aspell-dictionaries.rb5
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb18
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb9
-rw-r--r--Library/Homebrew/dev-cmd/man.rb9
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb4
-rw-r--r--Library/Homebrew/dev-cmd/test.rb2
6 files changed, 21 insertions, 26 deletions
diff --git a/Library/Homebrew/dev-cmd/aspell-dictionaries.rb b/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
index 955e41b01..ab0e66d2b 100644
--- a/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
+++ b/Library/Homebrew/dev-cmd/aspell-dictionaries.rb
@@ -27,13 +27,12 @@ module Homebrew
end
end
- languages.inject([]) do |resources, (lang, path)|
+ languages.each do |lang, path|
r = Resource.new(lang)
r.owner = Formulary.factory("aspell")
r.url "#{dict_url}/#{path}"
r.mirror "#{dict_mirror}/#{path}"
- resources << r
- end.each(&:fetch).each do |r|
+ r.fetch
puts <<-EOS
option "with-lang-#{r.name}", "Install #{r.name} dictionary"
resource "#{r.name}" do
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 16ae7cba1..6afd1f802 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -53,7 +53,7 @@ module Homebrew
module_function
def audit
- Homebrew.inject_dump_stats!(FormulaAuditor, /^audit_/) if ARGV.switch? "D"
+ inject_dump_stats!(FormulaAuditor, /^audit_/) if ARGV.switch? "D"
Homebrew.auditing = true
formula_count = 0
@@ -387,8 +387,10 @@ class FormulaAuditor
end
end
- # core aliases + tap alias names + tap alias full name
- @@aliases ||= Formula.aliases + Formula.tap_aliases
+ def self.aliases
+ # core aliases + tap alias names + tap alias full name
+ @aliases ||= Formula.aliases + Formula.tap_aliases
+ end
def audit_formula_name
return unless @strict
@@ -442,7 +444,7 @@ class FormulaAuditor
problem "Dependency '#{dep.name}' was renamed; use new name '#{dep_f.name}'."
end
- if @@aliases.include?(dep.name) &&
+ if self.class.aliases.include?(dep.name) &&
(dep_f.core_formula? || !dep_f.versioned_formula?)
problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
end
@@ -453,16 +455,16 @@ class FormulaAuditor
problem "Dependency '#{dep.name}' may be unnecessary as it is provided by macOS; try to build this formula without it."
end
- dep.options.reject do |opt|
- next true if dep_f.option_defined?(opt)
- dep_f.requirements.detect do |r|
+ dep.options.each do |opt|
+ next if dep_f.option_defined?(opt)
+ next if dep_f.requirements.detect do |r|
if r.recommended?
opt.name == "with-#{r.name}"
elsif r.optional?
opt.name == "without-#{r.name}"
end
end
- end.each do |opt|
+
problem "Dependency #{dep} does not define option #{opt.name.inspect}"
end
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index 8dfd0d12c..fb862c773 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -75,7 +75,7 @@ module Homebrew
@put_filenames ||= []
- return if @put_filenames.include? filename
+ return if @put_filenames.include?(filename)
puts Formatter.error(filename.to_s)
@put_filenames << filename
@@ -84,8 +84,7 @@ module Homebrew
result = false
keg.each_unique_file_matching(string) do |file|
- # skip document file.
- next if Metafiles::EXTENSIONS.include? file.extname
+ next if Metafiles::EXTENSIONS.include?(file.extname) # Skip document files.
linked_libraries = Keg.file_linked_libraries(file, string)
result ||= !linked_libraries.empty?
@@ -156,9 +155,7 @@ module Homebrew
return ofail "Formula not installed or up-to-date: #{f.full_name}"
end
- tap = f.tap
-
- unless tap
+ unless tap = f.tap
unless ARGV.include?("--force-core-tap")
return ofail "Formula not from core or any taps: #{f.full_name}"
end
diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb
index 472bb7c2b..b2bb3c8c3 100644
--- a/Library/Homebrew/dev-cmd/man.rb
+++ b/Library/Homebrew/dev-cmd/man.rb
@@ -48,12 +48,9 @@ module Homebrew
def path_glob_commands(glob)
Pathname.glob(glob)
.sort_by { |source_file| sort_key_for_path(source_file) }
- .map do |source_file|
- source_file.read.lines
- .grep(/^#:/)
- .map { |line| line.slice(2..-1) }
- .join
- end.reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") }
+ .map(&:read).map(&:lines)
+ .map { |lines| lines.grep(/^#:/).map { |line| line.slice(2..-1) }.join }
+ .reject { |s| s.strip.empty? || s.include?("@hide_from_man_page") }
end
def build_man_page
diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index cd0d6fbd0..8cb270303 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -154,8 +154,8 @@ module Homebrew
begin
f = Formula[name]
- # Make sure we catch syntax errors.
- rescue Exception
+ rescue Exception # rubocop:disable Lint/RescueException
+ # Make sure we catch syntax errors.
next
end
diff --git a/Library/Homebrew/dev-cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb
index ab2b0edb0..6622a8c25 100644
--- a/Library/Homebrew/dev-cmd/test.rb
+++ b/Library/Homebrew/dev-cmd/test.rb
@@ -84,7 +84,7 @@ module Homebrew
rescue ::Test::Unit::AssertionFailedError => e
ofail "#{f.full_name}: failed"
puts e.message
- rescue Exception => e
+ rescue Exception => e # rubocop:disable Lint/RescueException
ofail "#{f.full_name}: failed"
puts e, e.backtrace
ensure