From ca47992a6c71d9d0133e4deffffc2deab1e22458 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 22 May 2020 08:52:26 +0100 Subject: [PATCH] Fix rubocop-performance brew style. --- Library/Homebrew/cask/artifact/abstract_uninstall.rb | 2 +- Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/help.rb | 2 +- Library/Homebrew/rubocops/urls.rb | 2 +- Library/Homebrew/test/cmd/shared_examples/args_parse.rb | 5 +++-- Library/Homebrew/test/rubocops/patches_spec.rb | 8 ++++---- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 32d958f069..e3f99669ca 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -89,7 +89,7 @@ module Cask args: ["list", service], sudo: with_sudo, print_stderr: false ).stdout - if plist_status.match?(/^\{/) + if plist_status.start_with?("{") command.run!("/bin/launchctl", args: ["remove", service], sudo: with_sudo) sleep 1 end diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index deec12b9d6..82431558e7 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -984,7 +984,7 @@ module Homebrew except_audits = @except methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| - name = audit_method_name.gsub(/^audit_/, "") + name = audit_method_name.delete_prefix("audit_") if only_audits next unless only_audits.include?(name) elsif except_audits diff --git a/Library/Homebrew/help.rb b/Library/Homebrew/help.rb index 7e45247b75..0e41977c72 100644 --- a/Library/Homebrew/help.rb +++ b/Library/Homebrew/help.rb @@ -103,7 +103,7 @@ module Homebrew help_lines = command_help_lines(path) return if help_lines.blank? - Formatter.wrap(help_lines.join.gsub(/^ /, ""), COMMAND_DESC_WIDTH) + Formatter.wrap(help_lines.join.delete_prefix(" "), COMMAND_DESC_WIDTH) .sub("@hide_from_man_page ", "") .sub(/^\* /, "#{Tty.bold}Usage: brew#{Tty.reset} ") .gsub(/`(.*?)`/m, "#{Tty.bold}\\1#{Tty.reset}") diff --git a/Library/Homebrew/rubocops/urls.rb b/Library/Homebrew/rubocops/urls.rb index 429f5b8ebd..33c1ded388 100644 --- a/Library/Homebrew/rubocops/urls.rb +++ b/Library/Homebrew/rubocops/urls.rb @@ -230,7 +230,7 @@ module RuboCop # Use new-style archive downloads archive_gh_pattern = %r{https://.*github.*/(?:tar|zip)ball/} audit_urls(urls, archive_gh_pattern) do |_, url| - next if url.match?(/\.git$/) + next if url.end_with?(".git") problem "Use /archive/ URLs for GitHub tarballs (url is #{url})." end diff --git a/Library/Homebrew/test/cmd/shared_examples/args_parse.rb b/Library/Homebrew/test/cmd/shared_examples/args_parse.rb index 9cc16d455a..c9e8cc1d80 100644 --- a/Library/Homebrew/test/cmd/shared_examples/args_parse.rb +++ b/Library/Homebrew/test/cmd/shared_examples/args_parse.rb @@ -3,11 +3,12 @@ shared_examples "parseable arguments" do subject(:method_name) do |example| example.metadata[:example_group][:parent_example_group][:description] - .gsub(/^Homebrew\./, "") + .delete_prefix("Homebrew.") end let(:command_name) do - method_name.gsub(/_args$/, "").tr("_", "-") + method_name.delete_suffix("_args") + .tr("_", "-") end it "can parse arguments" do diff --git a/Library/Homebrew/test/rubocops/patches_spec.rb b/Library/Homebrew/test/rubocops/patches_spec.rb index d2ed6ce03a..f2a0fc25a7 100644 --- a/Library/Homebrew/test/rubocops/patches_spec.rb +++ b/Library/Homebrew/test/rubocops/patches_spec.rb @@ -68,7 +68,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do line: 5, column: 33, source: source }] - elsif patch_url.match?(%r{^http://trac\.macports\.org}) + elsif patch_url.start_with?("http://trac.macports.org") [{ message: <<~EOS.chomp, Patches from MacPorts Trac should be https://, not http: @@ -78,7 +78,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do line: 5, column: 5, source: source }] - elsif patch_url.match?(%r{^http://bugs\.debian\.org}) + elsif patch_url.start_with?("http://bugs.debian.org") [{ message: <<~EOS.chomp, Patches from Debian should be https://, not http: @@ -205,7 +205,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do line: 5, column: 37, source: source }] - elsif patch_url.match?(%r{^http://trac\.macports\.org}) + elsif patch_url.start_with?("http://trac.macports.org") [{ message: <<~EOS.chomp, Patches from MacPorts Trac should be https://, not http: @@ -215,7 +215,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do line: 5, column: 9, source: source }] - elsif patch_url.match?(%r{^http://bugs\.debian\.org}) + elsif patch_url.start_with?("http://bugs.debian.org") [{ message: <<~EOS.chomp, Patches from Debian should be https://, not http: