diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 7f86119abd..6a38e100f3 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -81,16 +81,6 @@ Metrics/ModuleLength: Metrics/ParameterLists: Max: 6 -# Offense count: 8 -Style/AccessorMethodName: - Exclude: - - 'Homebrew/download_strategy.rb' - - 'Homebrew/extend/ENV/std.rb' - - 'Homebrew/formula.rb' - - 'Homebrew/formula_lock.rb' - - 'Homebrew/formulary.rb' - - 'Homebrew/migrator.rb' - # Offense count: 1 Style/CaseEquality: Exclude: diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 38c7559fbd..ce10da52ad 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -27,7 +27,7 @@ require "formula" module Homebrew def inreplace_pairs(path, replacement_pairs) if ARGV.dry_run? - contents = path.open("r") { |f| Formulary.set_encoding(f).read } + contents = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } contents.extend(StringInreplaceExtension) replacement_pairs.each do |old, new| unless ARGV.flag?("--quiet") @@ -48,7 +48,7 @@ module Homebrew s.gsub!(old, new) end end - path.open("r") { |f| Formulary.set_encoding(f).read } + path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } end end diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 687e143960..1775e4e38d 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -560,7 +560,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy Utils.popen_read("svn", "info", cached_location.to_s).strip[/^URL: (.+)$/, 1] end - def get_externals + def externals Utils.popen_read("svn", "propget", "svn:externals", @url).chomp.each_line do |line| name, url = line.split(/\s+/) yield name, url @@ -600,7 +600,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy main_revision = @ref[:trunk] fetch_repo cached_location, @url, main_revision, true - get_externals do |external_name, external_url| + externals do |external_name, external_url| fetch_repo cached_location+external_name, external_url, @ref[external_name], true end else diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index ecd50ce065..c217ed8a51 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -30,7 +30,7 @@ module HomebrewArgvExtension if f.any_version_installed? tab = Tab.for_formula(f) resolved_spec = spec(nil) || tab.spec - f.set_active_spec(resolved_spec) if f.send(resolved_spec) + f.active_spec = resolved_spec if f.send(resolved_spec) f.build = tab if f.head? && tab.tabfile k = Keg.new(tab.tabfile.parent) diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index b56aa56f39..27dc95d297 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -42,7 +42,7 @@ module Stdenv end # Os is the default Apple uses for all its stuff so let's trust them - set_cflags "-Os #{SAFE_CFLAGS_FLAGS}" + define_cflags "-Os #{SAFE_CFLAGS_FLAGS}" append "LDFLAGS", "-Wl,-headerpad_max_install_names" @@ -136,12 +136,12 @@ module Stdenv end def minimal_optimization - set_cflags "-Os #{SAFE_CFLAGS_FLAGS}" + define_cflags "-Os #{SAFE_CFLAGS_FLAGS}" end alias generic_minimal_optimization minimal_optimization def no_optimization - set_cflags SAFE_CFLAGS_FLAGS + define_cflags SAFE_CFLAGS_FLAGS end alias generic_no_optimization no_optimization @@ -206,7 +206,7 @@ module Stdenv end # Convenience method to set all C compiler flags in one shot. - def set_cflags(val) + def define_cflags(val) CC_FLAG_VARS.each { |key| self[key] = val } end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 78dbc69404..4d3c143dce 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -179,12 +179,12 @@ class Formula Tap.fetch($1, $2) end - @full_name = get_full_name(name) - @full_alias_name = get_full_name(@alias_name) + @full_name = full_name_with_optional_tap(name) + @full_alias_name = full_name_with_optional_tap(@alias_name) - set_spec :stable - set_spec :devel - set_spec :head + spec_eval :stable + spec_eval :devel + spec_eval :head @active_spec = determine_active_spec(spec) @active_spec_sym = if head? @@ -201,7 +201,7 @@ class Formula end # @private - def set_active_spec(spec_sym) + def active_spec=(spec_sym) spec = send(spec_sym) raise FormulaSpecificationError, "#{spec_sym} spec is not available for #{full_name}" unless spec @active_spec = spec @@ -214,7 +214,7 @@ class Formula # Allow full name logic to be re-used between names, aliases, # and installed aliases. - def get_full_name(name) + def full_name_with_optional_tap(name) if name.nil? || @tap.nil? || @tap.core_tap? name else @@ -222,7 +222,7 @@ class Formula end end - def set_spec(name) + def spec_eval(name) spec = self.class.send(name) return unless spec.url spec.owner = self @@ -264,7 +264,7 @@ class Formula end def full_installed_alias_name - get_full_name(installed_alias_name) + full_name_with_optional_tap(installed_alias_name) end # The path that was specified to find this formula. diff --git a/Library/Homebrew/formula_lock.rb b/Library/Homebrew/formula_lock.rb index 4bd12df18e..bf747fea22 100644 --- a/Library/Homebrew/formula_lock.rb +++ b/Library/Homebrew/formula_lock.rb @@ -8,8 +8,8 @@ class FormulaLock end def lock - HOMEBREW_LOCK_DIR.mkpath - @lockfile = get_or_create_lockfile + @path.parent.mkpath + create_lockfile return if @lockfile.flock(File::LOCK_EX | File::LOCK_NB) raise OperationInProgressError, @name end @@ -29,12 +29,9 @@ class FormulaLock private - def get_or_create_lockfile - if @lockfile.nil? || @lockfile.closed? - @lockfile = @path.open(File::RDWR | File::CREAT) - @lockfile.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) - end - - @lockfile + def create_lockfile + return unless @lockfile.nil? || @lockfile.closed? + @lockfile = @path.open(File::RDWR | File::CREAT) + @lockfile.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) end end diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index e3c893fd64..5ce09f6ba5 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -37,18 +37,18 @@ class Formulary end def self.load_formula_from_path(name, path) - contents = path.open("r") { |f| set_encoding(f).read } + contents = path.open("r") { |f| ensure_utf8_encoding(f).read } namespace = "FormulaNamespace#{Digest::MD5.hexdigest(path.to_s)}" klass = load_formula(name, path, contents, namespace) FORMULAE[path] = klass end if IO.method_defined?(:set_encoding) - def self.set_encoding(io) + def self.ensure_utf8_encoding(io) io.set_encoding(Encoding::UTF_8) end else - def self.set_encoding(io) + def self.ensure_utf8_encoding(io) io end end diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb index addd97c8a9..4f8cba1ce0 100644 --- a/Library/Homebrew/migrator.rb +++ b/Library/Homebrew/migrator.rb @@ -101,7 +101,7 @@ class Migrator @new_cellar = HOMEBREW_CELLAR/formula.name - if @old_linked_keg = get_linked_old_linked_keg + if @old_linked_keg = linked_old_linked_keg @old_linked_keg_record = old_linked_keg.linked_keg_record if old_linked_keg.linked? @old_opt_record = old_linked_keg.opt_record if old_linked_keg.optlinked? @new_linked_keg_record = HOMEBREW_CELLAR/"#{newname}/#{File.basename(old_linked_keg)}" @@ -137,7 +137,7 @@ class Migrator end end - def get_linked_old_linked_keg + def linked_old_linked_keg kegs = old_cellar.subdirs.map { |d| Keg.new(d) } kegs.detect(&:linked?) || kegs.detect(&:optlinked?) end diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 9207f8ead7..37d3f0f596 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -467,7 +467,7 @@ class FormulaTests < Homebrew::TestCase assert_version_equal "HEAD", f.head.version end - def test_formula_set_active_spec + def test_formula_active_spec= f = formula do url "foo" version "1.0" @@ -481,11 +481,11 @@ class FormulaTests < Homebrew::TestCase assert_equal :stable, f.active_spec_sym assert_equal f.stable, f.send(:active_spec) assert_equal "1.0_1", f.pkg_version.to_s - f.set_active_spec(:devel) + f.active_spec = :devel assert_equal :devel, f.active_spec_sym assert_equal f.devel, f.send(:active_spec) assert_equal "1.0beta_1", f.pkg_version.to_s - assert_raises(FormulaSpecificationError) { f.set_active_spec(:head) } + assert_raises(FormulaSpecificationError) { f.active_spec = :head } end def test_path