Fix rubocop-performance brew style.

This commit is contained in:
Mike McQuaid 2020-05-22 08:52:26 +01:00
parent d02b15d31a
commit ca47992a6c
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
6 changed files with 11 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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}")

View File

@ -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

View File

@ -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

View File

@ -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: