From 9dee80cb2daf2a6299195a50156718386d24512b Mon Sep 17 00:00:00 2001 From: Patrick Linnane Date: Mon, 18 Dec 2023 09:34:01 -0800 Subject: [PATCH] various: fix style errors --- Library/Homebrew/brew.rb | 2 +- Library/Homebrew/cask/artifact/abstract_uninstall.rb | 2 +- Library/Homebrew/cask/dsl.rb | 10 +++++----- Library/Homebrew/compilers.rb | 2 +- Library/Homebrew/extend/on_system.rb | 8 ++++---- Library/Homebrew/extend/os/linux/hardware/cpu.rb | 2 +- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/locale.rb | 2 +- Library/Homebrew/tab.rb | 2 +- Library/Homebrew/test/github_runner_spec.rb | 2 +- Library/Homebrew/test/linux_runner_spec_spec.rb | 2 +- Library/Homebrew/test/macos_runner_spec_spec.rb | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index c5e5bf5b13..78b51cb55c 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -89,7 +89,7 @@ begin exit Homebrew.failed? ? 1 : 0 elsif Commands.external_cmd_path(cmd) %w[CACHE LIBRARY_PATH].each do |env| - ENV["HOMEBREW_#{env}"] = Object.const_get("HOMEBREW_#{env}").to_s + ENV["HOMEBREW_#{env}"] = Object.const_get(:"HOMEBREW_#{env}").to_s end exec "brew-#{cmd}", *ARGV else diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 78547326b5..efc63b5f1e 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -72,7 +72,7 @@ module Cask args = directives[directive_sym] - send("uninstall_#{directive_sym}", *(args.is_a?(Hash) ? [args] : args), **options) + send(:"uninstall_#{directive_sym}", *(args.is_a?(Hash) ? [args] : args), **options) end def stanza diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index e6c31b8ec3..978251abb3 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -127,20 +127,20 @@ module Cask end def set_unique_stanza(stanza, should_return) - return instance_variable_get("@#{stanza}") if should_return + return instance_variable_get(:"@#{stanza}") if should_return unless @cask.allow_reassignment - if instance_variable_defined?("@#{stanza}") && !@called_in_on_system_block + if instance_variable_defined?(:"@#{stanza}") && !@called_in_on_system_block raise CaskInvalidError.new(cask, "'#{stanza}' stanza may only appear once.") end - if instance_variable_defined?("@#{stanza}_set_in_block") && @called_in_on_system_block + if instance_variable_defined?(:"@#{stanza}_set_in_block") && @called_in_on_system_block raise CaskInvalidError.new(cask, "'#{stanza}' stanza may only be overridden once.") end end - instance_variable_set("@#{stanza}_set_in_block", true) if @called_in_on_system_block - instance_variable_set("@#{stanza}", yield) + instance_variable_set(:"@#{stanza}_set_in_block", true) if @called_in_on_system_block + instance_variable_set(:"@#{stanza}", yield) rescue CaskInvalidError raise rescue => e diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 12ac6cdb22..bd49263dd8 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -173,7 +173,7 @@ class CompilerSelector when "gcc", GNU_GCC_REGEXP versions.gcc_version(name.to_s) else - versions.send("#{name}_build_version") + versions.send(:"#{name}_build_version") end end end diff --git a/Library/Homebrew/extend/on_system.rb b/Library/Homebrew/extend/on_system.rb index 6ebeef7ab8..5df367ac84 100644 --- a/Library/Homebrew/extend/on_system.rb +++ b/Library/Homebrew/extend/on_system.rb @@ -18,7 +18,7 @@ module OnSystem sig { params(os_name: Symbol, or_condition: T.nilable(Symbol)).returns(T::Boolean) } def self.os_condition_met?(os_name, or_condition = nil) - return Homebrew::SimulateSystem.send("simulating_or_running_on_#{os_name}?") if BASE_OS_OPTIONS.include?(os_name) + return Homebrew::SimulateSystem.send(:"simulating_or_running_on_#{os_name}?") if BASE_OS_OPTIONS.include?(os_name) raise ArgumentError, "Invalid OS condition: #{os_name.inspect}" unless MacOSVersion::SYMBOLS.key?(os_name) @@ -51,7 +51,7 @@ module OnSystem sig { params(base: Class).void } def self.setup_arch_methods(base) ARCH_OPTIONS.each do |arch| - base.define_method("on_#{arch}") do |&block| + base.define_method(:"on_#{arch}") do |&block| @on_system_blocks_exist = true return unless OnSystem.arch_condition_met? OnSystem.condition_from_method_name(T.must(__method__)) @@ -78,7 +78,7 @@ module OnSystem sig { params(base: Class).void } def self.setup_base_os_methods(base) BASE_OS_OPTIONS.each do |base_os| - base.define_method("on_#{base_os}") do |&block| + base.define_method(:"on_#{base_os}") do |&block| @on_system_blocks_exist = true return unless OnSystem.os_condition_met? OnSystem.condition_from_method_name(T.must(__method__)) @@ -124,7 +124,7 @@ module OnSystem sig { params(base: Class).void } def self.setup_macos_methods(base) MacOSVersion::SYMBOLS.each_key do |os_name| - base.define_method("on_#{os_name}") do |or_condition = nil, &block| + base.define_method(:"on_#{os_name}") do |or_condition = nil, &block| @on_system_blocks_exist = true os_condition = OnSystem.condition_from_method_name T.must(__method__) diff --git a/Library/Homebrew/extend/os/linux/hardware/cpu.rb b/Library/Homebrew/extend/os/linux/hardware/cpu.rb index 12762704bc..1ae24e1d73 100644 --- a/Library/Homebrew/extend/os/linux/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/linux/hardware/cpu.rb @@ -111,7 +111,7 @@ module Hardware end %w[aes altivec avx avx2 lm ssse3 sse4_2].each do |flag| - define_method("#{flag}?") do + define_method(:"#{flag}?") do T.bind(self, T.class_of(Hardware::CPU)) flags.include? flag end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index cdae57e8b8..ac99e16df6 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -295,7 +295,7 @@ class Formula spec.owner = self add_global_deps_to_spec(spec) - instance_variable_set("@#{name}", spec) + instance_variable_set(:"@#{name}", spec) end sig { params(spec: SoftwareSpec).void } diff --git a/Library/Homebrew/locale.rb b/Library/Homebrew/locale.rb index 7979f1fc3d..2f2863a7b6 100644 --- a/Library/Homebrew/locale.rb +++ b/Library/Homebrew/locale.rb @@ -69,7 +69,7 @@ class Locale }.each do |key, value| next if value.nil? - regex = self.class.const_get("#{key.upcase}_REGEX") + regex = self.class.const_get(:"#{key.upcase}_REGEX") raise ParserError, "'#{value}' does not match #{regex}" unless value&.match?(regex) instance_variable_set(:"@#{key}", value) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 4070738df6..d38503bde7 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -234,7 +234,7 @@ class Tab end def initialize(attributes = {}) - attributes.each { |key, value| instance_variable_set("@#{key}", value) } + attributes.each { |key, value| instance_variable_set(:"@#{key}", value) } end def any_args_or_options? diff --git a/Library/Homebrew/test/github_runner_spec.rb b/Library/Homebrew/test/github_runner_spec.rb index bcbadf07bc..7859b0325b 100644 --- a/Library/Homebrew/test/github_runner_spec.rb +++ b/Library/Homebrew/test/github_runner_spec.rb @@ -11,7 +11,7 @@ describe GitHubRunner do it "has immutable attributes" do [:platform, :arch, :spec, :macos_version].each do |attribute| - expect(runner.respond_to?("#{attribute}=")).to be(false) + expect(runner.respond_to?(:"#{attribute}=")).to be(false) end end diff --git a/Library/Homebrew/test/linux_runner_spec_spec.rb b/Library/Homebrew/test/linux_runner_spec_spec.rb index 1c63d63615..010b550790 100644 --- a/Library/Homebrew/test/linux_runner_spec_spec.rb +++ b/Library/Homebrew/test/linux_runner_spec_spec.rb @@ -16,7 +16,7 @@ describe LinuxRunnerSpec do it "has immutable attributes" do [:name, :runner, :container, :workdir, :timeout, :cleanup].each do |attribute| - expect(spec.respond_to?("#{attribute}=")).to be(false) + expect(spec.respond_to?(:"#{attribute}=")).to be(false) end end diff --git a/Library/Homebrew/test/macos_runner_spec_spec.rb b/Library/Homebrew/test/macos_runner_spec_spec.rb index e0711b1909..e676434d58 100644 --- a/Library/Homebrew/test/macos_runner_spec_spec.rb +++ b/Library/Homebrew/test/macos_runner_spec_spec.rb @@ -7,7 +7,7 @@ describe MacOSRunnerSpec do it "has immutable attributes" do [:name, :runner, :timeout, :cleanup].each do |attribute| - expect(spec.respond_to?("#{attribute}=")).to be(false) + expect(spec.respond_to?(:"#{attribute}=")).to be(false) end end