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

Add new odeprecated, odisabled, remove disabled code. #18388

Merged
merged 1 commit into from
Sep 25, 2024
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
6 changes: 3 additions & 3 deletions Library/Homebrew/cask/artifact/moved.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
end

# Remove the source as we don't need to move it to the target location
source.rmtree
FileUtils.rm_r(source)

return post_move(command)
end
Expand All @@ -112,14 +112,14 @@
sudo: true)
end
Quarantine.copy_xattrs(source, target, command:)
source.rmtree
FileUtils.rm_r(source)
elsif target.dirname.writable?
FileUtils.move(source, target)
else
# default sudo user isn't necessarily able to write to Homebrew's locations
# e.g. with runas_default set in the sudoers (5) file.
command.run!("/bin/cp", args: ["-pR", source, target], sudo: true)
source.rmtree
FileUtils.rm_r(source)

Check warning on line 122 in Library/Homebrew/cask/artifact/moved.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cask/artifact/moved.rb#L122

Added line #L122 was not covered by tests
end

post_move(command)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
end

def discontinued?
odeprecated "`discontinued?`", "`deprecated?` or `disabled?`"
odisabled "`discontinued?`", "`deprecated?` or `disabled?`"

Check warning on line 414 in Library/Homebrew/cask/dsl.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cask/dsl.rb#L414

Added line #L414 was not covered by tests
@caveats&.discontinued? == true
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/caveats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
end

caveat :discontinued do
odeprecated "`caveats :discontinued`", "`deprecate!`"
odisabled "`caveats :discontinued`", "`deprecate!`"

Check warning on line 167 in Library/Homebrew/cask/dsl/caveats.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cask/dsl/caveats.rb#L167

Added line #L167 was not covered by tests
@discontinued = true
<<~EOS
#{@cask} has been officially discontinued upstream.
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def save_caskfile

extension = @cask.loaded_from_api? ? "json" : "rb"
(metadata_subdir/"#{@cask.token}.#{extension}").write @cask.source
old_savedir&.rmtree
FileUtils.rm_r(old_savedir) if old_savedir
end

def save_config_file
Expand Down Expand Up @@ -454,8 +454,8 @@ def backup
def restore_backup
return if !backup_path.directory? || !backup_metadata_path.directory?

@cask.staged_path.rmtree if @cask.staged_path.exist?
@cask.metadata_versioned_path.rmtree if @cask.metadata_versioned_path.exist?
FileUtils.rm_r(@cask.staged_path) if @cask.staged_path.exist?
FileUtils.rm_r(@cask.metadata_versioned_path) if @cask.metadata_versioned_path.exist?

backup_path.rename @cask.staged_path
backup_metadata_path.rename @cask.metadata_versioned_path
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def self.gain_permissions_remove(path, command: SystemCommand)
gain_permissions(path, permission_flags, command) do |p|
if p.parent.writable?
if directory
p.rmtree
FileUtils.rm_r p
else
FileUtils.rm_f p
end
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
logs_days = [days, CLEANUP_DEFAULT_DAYS].min

HOMEBREW_LOGS.subdirs.each do |dir|
cleanup_path(dir) { dir.rmtree } if self.class.prune?(dir, logs_days)
cleanup_path(dir) { FileUtils.rm_r(dir) } if self.class.prune?(dir, logs_days)
end
end

Expand Down Expand Up @@ -518,7 +518,7 @@
end

portable_rubies_to_remove.each do |portable_ruby|
cleanup_path(portable_ruby) { portable_ruby.rmtree }
cleanup_path(portable_ruby) { FileUtils.rm_r(portable_ruby) }

Check warning on line 521 in Library/Homebrew/cleanup.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cleanup.rb#L521

Added line #L521 was not covered by tests
end
end

Expand All @@ -531,7 +531,7 @@
return unless bootsnap.directory?

bootsnap.each_child do |subdir|
cleanup_path(subdir) { subdir.rmtree } if subdir.basename.to_s != Homebrew.bootsnap_key
cleanup_path(subdir) { FileUtils.rm_r(subdir) } if subdir.basename.to_s != Homebrew.bootsnap_key
end
end

Expand Down
10 changes: 5 additions & 5 deletions Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@
@command_name = T.let(T.must(cmd_location.label).chomp("_args").tr("_", "-"), String)
@is_dev_cmd = T.let(T.must(cmd_location.absolute_path).start_with?(Commands::HOMEBREW_DEV_CMD_PATH),
T::Boolean)
# odeprecated(
# "`brew #{@command_name}'. This command needs to be refactored, as it is written in a style that",
# "inheritance from `Homebrew::AbstractCommand' ( see https://docs.brew.sh/External-Commands )",
# disable_for_developers: false,
# )
odeprecated(

Check warning on line 169 in Library/Homebrew/cli/parser.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cli/parser.rb#L169

Added line #L169 was not covered by tests
"`brew #{@command_name}'. This command needs to be refactored, as it is written in a style that",
"inherits from `Homebrew::AbstractCommand' ( see https://docs.brew.sh/External-Commands )",
disable_for_developers: false,
)
end

@constraints = T.let([], T::Array[[String, String]])
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/cmd/update-report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ def initialize(tap, api_names_txt: nil, api_names_before_txt: nil, api_dir_prefi
@api_names_before_txt = api_names_before_txt
@api_dir_prefix = api_dir_prefix
else
initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{tap.repo_var_suffix}"
initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{tap.repository_var_suffix}"
@initial_revision = ENV[initial_revision_var].to_s
raise ReporterRevisionUnsetError, initial_revision_var if @initial_revision.empty?

current_revision_var = "HOMEBREW_UPDATE_AFTER#{tap.repo_var_suffix}"
current_revision_var = "HOMEBREW_UPDATE_AFTER#{tap.repository_var_suffix}"
@current_revision = ENV[current_revision_var].to_s
raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty?
end
Expand Down
20 changes: 10 additions & 10 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ git_init_if_necessary() {
fi
}

repo_var_suffix() {
local repo_dir="${1}"
local repo_var_suffix
repository_var_suffix() {
local repository_directory="${1}"
local repository_var_suffix

if [[ "${repo_dir}" == "${HOMEBREW_REPOSITORY}" ]]
if [[ "${repository_directory}" == "${HOMEBREW_REPOSITORY}" ]]
then
repo_var_suffix=""
repository_var_suffix=""
else
repo_var_suffix="${repo_dir#"${HOMEBREW_LIBRARY}/Taps"}"
repo_var_suffix="$(echo -n "${repo_var_suffix}" | tr -C "A-Za-z0-9" "_" | tr "[:lower:]" "[:upper:]")"
repository_var_suffix="${repository_directory#"${HOMEBREW_LIBRARY}/Taps"}"
repository_var_suffix="$(echo -n "${repository_var_suffix}" | tr -C "A-Za-z0-9" "_" | tr "[:lower:]" "[:upper:]")"
fi
echo "${repo_var_suffix}"
echo "${repository_var_suffix}"
}

upstream_branch() {
Expand Down Expand Up @@ -592,7 +592,7 @@ EOS
echo "Checking if we need to fetch ${DIR}..."
fi

TAP_VAR="$(repo_var_suffix "${DIR}")"
TAP_VAR="$(repository_var_suffix "${DIR}")"
UPSTREAM_BRANCH_DIR="$(upstream_branch)"
declare UPSTREAM_BRANCH"${TAP_VAR}"="${UPSTREAM_BRANCH_DIR}"
declare PREFETCH_REVISION"${TAP_VAR}"="$(git rev-parse -q --verify refs/remotes/origin/"${UPSTREAM_BRANCH_DIR}")"
Expand Down Expand Up @@ -778,7 +778,7 @@ EOS
continue
fi

TAP_VAR="$(repo_var_suffix "${DIR}")"
TAP_VAR="$(repository_var_suffix "${DIR}")"
UPSTREAM_BRANCH_VAR="UPSTREAM_BRANCH${TAP_VAR}"
UPSTREAM_BRANCH="${!UPSTREAM_BRANCH_VAR}"
CURRENT_REVISION="$(read_current_revision)"
Expand Down
7 changes: 0 additions & 7 deletions Library/Homebrew/cmd/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ class UpgradeCmd < AbstractCommand
"formula is outdated. Otherwise, the repository's HEAD will only be checked for " \
"updates when a new stable or development version has been released.",
}],
[:switch, "--ignore-pinned", {
description: "Set a successful exit status even if pinned formulae are not upgraded.",
hidden: true,
}],
[:switch, "--keep-tmp", {
description: "Retain the temporary files created during installation.",
}],
Expand Down Expand Up @@ -124,9 +120,6 @@ class UpgradeCmd < AbstractCommand

sig { override.void }
def run
# Disabled since this is now the default behavior.
odisabled "`brew upgrade --ignore-pinned`" if args.ignore_pinned?

formulae, casks = args.named.to_resolved_formulae_to_casks
# If one or more formulae are specified, but no casks were
# specified, we want to make note of that so we don't
Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/dev-cmd/bump-cask-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class BumpCaskPr < AbstractCommand
"to the cask file."
switch "--no-audit",
description: "Don't run `brew audit` before opening the PR."
switch "--online",
hidden: true
switch "--no-style",
description: "Don't run `brew style --fix` before opening the PR."
switch "--no-browse",
Expand Down Expand Up @@ -60,8 +58,6 @@ class BumpCaskPr < AbstractCommand

sig { override.void }
def run
odisabled "brew bump-cask-pr --online" if args.online?

# This will be run by `brew audit` or `brew style` later so run it first to
# not start spamming during normal output.
gem_groups = []
Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,6 @@ def check_throttle(formula, new_version)
return if tap.nil?

throttled_rate = formula.livecheck.throttle
throttled_rate ||= if (rate = tap.audit_exceptions.dig(:throttled_formulae, formula.name))
odisabled "throttled_formulae.json", "Livecheck#throttle"
rate
end
return if throttled_rate.blank?

formula_suffix = Version.new(new_version).patch.to_i
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/dev-cmd/prof.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def run
Homebrew.setup_gem_environment!

if args.stackprof?
# odeprecated. vernier is better in every way
with_env HOMEBREW_STACKPROF: "1" do
system(*HOMEBREW_RUBY_EXEC_ARGS, brew_rb, *args.named)
end
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/dev-cmd/tap-new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ def run
odie "Tap is already installed!" if tap.installed?

titleized_user = tap.user.dup
titleized_repo = tap.repo.dup
titleized_repository = tap.repository.dup
titleized_user[0] = titleized_user[0].upcase
titleized_repo[0] = titleized_repo[0].upcase
root_url = GitHubPackages.root_url(tap.user, "homebrew-#{tap.repo}") if args.github_packages?
titleized_repository[0] = titleized_repository[0].upcase
root_url = GitHubPackages.root_url(tap.user, "homebrew-#{tap.repository}") if args.github_packages?

(tap.path/"Formula").mkpath

# FIXME: https://github.com/errata-ai/vale/issues/818
# <!-- vale off -->
readme = <<~MARKDOWN
# #{titleized_user} #{titleized_repo}
# #{titleized_user} #{titleized_repository}
## How do I install these formulae?
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@

def check_deprecated_official_taps
tapped_deprecated_taps =
Tap.select(&:official?).map(&:repo) & DEPRECATED_OFFICIAL_TAPS
Tap.select(&:official?).map(&:repository) & DEPRECATED_OFFICIAL_TAPS

Check warning on line 563 in Library/Homebrew/diagnostic.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/diagnostic.rb#L563

Added line #L563 was not covered by tests
return if tapped_deprecated_taps.empty?

<<~EOS
Expand Down
7 changes: 0 additions & 7 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ def quiet!
@quiet = true
end

# Disable any output during downloading.
sig { void }
def shutup!
odisabled "`AbstractDownloadStrategy#shutup!`", "`AbstractDownloadStrategy#quiet!`"
quiet!
end

def quiet?
Context.current.quiet? || @quiet
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ def initialize(name, error)

# Raised when a formula in a specific tap is unavailable.
class TapFormulaUnavailableError < FormulaUnavailableError
attr_reader :tap, :user, :repo
attr_reader :tap, :user, :repository

def initialize(tap, name)
@tap = tap
@user = tap.user
@repo = tap.repo
@repository = tap.repository
super "#{tap}/#{name}"
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def odeprecated(method, replacement = nil,

require "tap"

tap = Tap.fetch(match[:user], match[:repo])
tap = Tap.fetch(match[:user], match[:repository])
tap_message = +"\nPlease report this issue to the #{tap.full_name} tap"
tap_message += " (not Homebrew/brew or Homebrew/homebrew-core)" unless tap.official?
tap_message += ", or even better, submit a PR to fix it" if replacement
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 @@ -509,7 +509,7 @@
# create a RuboCop autocorrect instead soon.
# This is why monkeypatching is non-ideal (but right solution to get
# Ruby 3.3 over the line).
# odeprecated "rmtree", "FileUtils#rm_r"
odeprecated "rmtree", "FileUtils#rm_r"

Check warning on line 512 in Library/Homebrew/extend/pathname.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/pathname.rb#L512

Added line #L512 was not covered by tests
FileUtils.rm_r(@path, noop:, verbose:, secure:)
nil
end
Expand Down
12 changes: 6 additions & 6 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@
#
# @see https://www.unix.com/man-page/all/5/plist/ <code>plist(5)</code> man page
def plist
odeprecated "`Formula#plist`", "`Homebrew::Service`"
odisabled "`Formula#plist`", "`Homebrew::Service`"

Check warning on line 1237 in Library/Homebrew/formula.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula.rb#L1237

Added line #L1237 was not covered by tests
nil
end

Expand Down Expand Up @@ -2777,12 +2777,12 @@
).returns(Pathname)
}
def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
# odeprecated "Formula#fetch", "Resource#fetch on Formula#resource"
odeprecated "Formula#fetch", "Resource#fetch on Formula#resource"

Check warning on line 2780 in Library/Homebrew/formula.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula.rb#L2780

Added line #L2780 was not covered by tests
active_spec.fetch(verify_download_integrity:, timeout:, quiet:)
end

def verify_download_integrity(filename)
# odeprecated "Formula#verify_download_integrity", "Resource#verify_download_integrity on Formula#resource"
odeprecated "Formula#verify_download_integrity", "Resource#verify_download_integrity on Formula#resource"

Check warning on line 2785 in Library/Homebrew/formula.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula.rb#L2785

Added line #L2785 was not covered by tests
active_spec.verify_download_integrity(filename)
end

Expand Down Expand Up @@ -2887,8 +2887,8 @@
def inreplace(paths, before = nil, after = nil, old_audit_result = nil, audit_result: true, &block)
# NOTE: must check for `#nil?` and not `#blank?`, or else `old_audit_result = false` will not call `odeprecated`.
unless old_audit_result.nil?
# odeprecated "inreplace(paths, before, after, #{old_audit_result})",
# "inreplace(paths, before, after, audit_result: #{old_audit_result})"
odeprecated "inreplace(paths, before, after, #{old_audit_result})",
"inreplace(paths, before, after, audit_result: #{old_audit_result})"
audit_result = old_audit_result
end
Utils::Inreplace.inreplace(paths, before, after, audit_result:, &block)
Expand Down Expand Up @@ -3749,7 +3749,7 @@
#
# @api public
def go_resource(name, &block)
odeprecated "`Formula.go_resource`", "Go modules"
odisabled "`Formula.go_resource`", "Go modules"

Check warning on line 3752 in Library/Homebrew/formula.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula.rb#L3752

Added line #L3752 was not covered by tests
specs.each { |spec| spec.go_resource(name, &block) }
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/formula_auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ def audit_reverse_migration
problem <<~EOS
#{formula.name} seems to be listed in tap_migrations.json!
Please remove #{formula.name} from present tap & tap_migrations.json
before submitting it to Homebrew/homebrew-#{formula.tap.repo}.
before submitting it to Homebrew/homebrew-#{formula.tap.repository}.
EOS
end

Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def install
# any exceptions must leave us with nothing installed
ignore_interrupts do
begin
formula.prefix.rmtree if formula.prefix.directory?
FileUtils.rm_r(formula.prefix) if formula.prefix.directory?
rescue Errno::EACCES, Errno::ENOTEMPTY
odie <<~EOS
Could not remove #{formula.prefix.basename} keg! Do so manually:
Expand Down Expand Up @@ -825,7 +825,7 @@ def install_dependency(dep, inherited_options)
# dependency tree. In that case, don't generate an error, just move on.
nil
else
ignore_interrupts { tmp_keg.rmtree if tmp_keg&.directory? }
ignore_interrupts { FileUtils.rm_r(tmp_keg) if tmp_keg&.directory? }
end

sig { void }
Expand Down Expand Up @@ -1020,7 +1020,7 @@ def build
ignore_interrupts do
# any exceptions must leave us with nothing installed
formula.update_head_version
formula.prefix.rmtree if formula.prefix.directory?
FileUtils.rm_r(formula.prefix) if formula.prefix.directory?
formula.rack.rmdir_if_possible
end
raise e
Expand Down
Loading
Loading