Fix brew style.

This commit is contained in:
Mike McQuaid 2020-07-07 13:12:37 +01:00
parent d2e22986cd
commit fa760a2f26
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
9 changed files with 16 additions and 15 deletions

View File

@ -561,7 +561,7 @@ module Homebrew
return if !Utils.git_available? || !(coretap_path/".git").exist? return if !Utils.git_available? || !(coretap_path/".git").exist?
branch = coretap_path.git_branch branch = coretap_path.git_branch
return if branch.nil? || branch =~ /master/ return if branch.blank? || branch.include?("master")
<<~EOS <<~EOS
#{CoreTap.instance.full_name} is not on the master branch. #{CoreTap.instance.full_name} is not on the master branch.

View File

@ -191,7 +191,8 @@ module Homebrew
def check_xcode_license_approved def check_xcode_license_approved
# If the user installs Xcode-only, they have to approve the # If the user installs Xcode-only, they have to approve the
# license or no "xc*" tool will work. # license or no "xc*" tool will work.
return unless `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$CHILD_STATUS.success? return unless `/usr/bin/xcrun clang 2>&1`.include?("license")
return if $CHILD_STATUS.success?
<<~EOS <<~EOS
You have not agreed to the Xcode license. You have not agreed to the Xcode license.

View File

@ -268,7 +268,7 @@ module Language
t.stage { do_install Pathname.pwd } t.stage { do_install Pathname.pwd }
else else
t = t.lines.map(&:strip) if t.respond_to?(:lines) && t =~ /\n/ t = t.lines.map(&:strip) if t.respond_to?(:lines) && t.include?("\n")
do_install t do_install t
end end
end end

View File

@ -86,7 +86,7 @@ class JavaRequirement < Requirement
end end
def exact_version? def exact_version?
@version && @version.to_s.chars.last != "+" @version && @version.to_s[-1] != "+"
end end
def fits_latest? def fits_latest?

View File

@ -47,7 +47,7 @@ module RuboCop
# Check if command-line is wrongly used in formula's desc # Check if command-line is wrongly used in formula's desc
if match = regex_match_group(desc, /(command ?line)/i) if match = regex_match_group(desc, /(command ?line)/i)
c = match.to_s.chars.first c = match.to_s[0]
problem "Description should use \"#{c}ommand-line\" instead of \"#{match}\"" problem "Description should use \"#{c}ommand-line\" instead of \"#{match}\""
end end
@ -86,7 +86,7 @@ module RuboCop
correction = node.source correction = node.source
first_word = string_content(node).split.first first_word = string_content(node).split.first
unless VALID_LOWERCASE_WORDS.include?(first_word) unless VALID_LOWERCASE_WORDS.include?(first_word)
first_char = first_word.to_s.chars.first first_char = first_word.to_s[0]
correction.sub!(/^(['"]?)([a-z])/, "\\1#{first_char.upcase}") if first_char correction.sub!(/^(['"]?)([a-z])/, "\\1#{first_char.upcase}") if first_char
end end
correction.sub!(/^(['"]?)an?\s/i, "\\1") correction.sub!(/^(['"]?)an?\s/i, "\\1")

View File

@ -37,7 +37,7 @@ module RuboCop
# https://wiki.freedesktop.org/project_name. # https://wiki.freedesktop.org/project_name.
# "Software" is redirected to https://wiki.freedesktop.org/www/Software/project_name # "Software" is redirected to https://wiki.freedesktop.org/www/Software/project_name
when %r{^http://((?:www|nice|libopenraw|liboil|telepathy|xorg)\.)?freedesktop\.org/(?:wiki/)?} when %r{^http://((?:www|nice|libopenraw|liboil|telepathy|xorg)\.)?freedesktop\.org/(?:wiki/)?}
if homepage =~ /Software/ if homepage.include?("Software")
problem "#{homepage} should be styled `https://wiki.freedesktop.org/www/Software/project_name`" problem "#{homepage} should be styled `https://wiki.freedesktop.org/www/Software/project_name`"
else else
problem "#{homepage} should be styled `https://wiki.freedesktop.org/project_name`" problem "#{homepage} should be styled `https://wiki.freedesktop.org/project_name`"

View File

@ -247,7 +247,7 @@ module RuboCop
# Don't use GitHub .zip files # Don't use GitHub .zip files
zip_gh_pattern = %r{https://.*github.*/(archive|releases)/.*\.zip$} zip_gh_pattern = %r{https://.*github.*/(archive|releases)/.*\.zip$}
audit_urls(urls, zip_gh_pattern) do |_, url| audit_urls(urls, zip_gh_pattern) do |_, url|
next if url.match?(%r{releases/download}) next if url.include?("releases/download")
problem "Use GitHub tarballs rather than zipballs (url is #{url})." problem "Use GitHub tarballs rather than zipballs (url is #{url})."
end end

View File

@ -73,8 +73,8 @@ describe RuboCop::Cop::FormulaAudit::Homepage do
RUBY RUBY
inspect_source(source) inspect_source(source)
if homepage.match?(%r{http://www\.freedesktop\.org}) if homepage.include?("http://www.freedesktop.org")
if homepage.match?(/Software/) if homepage.include?("Software")
expected_offenses = [{ message: "#{homepage} should be styled " \ expected_offenses = [{ message: "#{homepage} should be styled " \
"`https://wiki.freedesktop.org/www/Software/project_name`", "`https://wiki.freedesktop.org/www/Software/project_name`",
severity: :convention, severity: :convention,
@ -89,7 +89,7 @@ describe RuboCop::Cop::FormulaAudit::Homepage do
column: 2, column: 2,
source: source }] source: source }]
end end
elsif homepage.match?(%r{https://code\.google\.com}) elsif homepage.include?("https://code.google.com")
expected_offenses = [{ message: "#{homepage} should end with a slash", expected_offenses = [{ message: "#{homepage} should end with a slash",
severity: :convention, severity: :convention,
line: 2, line: 2,

View File

@ -48,7 +48,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
EOS EOS
inspect_source(source) inspect_source(source)
expected_offense = if patch_url.match?(%r{/raw\.github\.com/}) expected_offense = if patch_url.include?("/raw.github.com/")
[{ message: [{ message:
<<~EOS.chomp, <<~EOS.chomp,
GitHub/Gist patches should specify a revision: GitHub/Gist patches should specify a revision:
@ -58,7 +58,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
line: 5, line: 5,
column: 12, column: 12,
source: source }] source: source }]
elsif patch_url.match?(%r{macports/trunk}) elsif patch_url.include?("macports/trunk")
[{ message: [{ message:
<<~EOS.chomp, <<~EOS.chomp,
MacPorts patches should specify a revision instead of trunk: MacPorts patches should specify a revision instead of trunk:
@ -232,7 +232,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
RUBY RUBY
inspect_source(source) inspect_source(source)
expected_offense = if patch_url.match?(%r{/raw\.github\.com/}) expected_offense = if patch_url.include?("/raw.github.com/")
[{ message: [{ message:
<<~EOS.chomp, <<~EOS.chomp,
GitHub/Gist patches should specify a revision: GitHub/Gist patches should specify a revision:
@ -242,7 +242,7 @@ describe RuboCop::Cop::FormulaAudit::Patches do
line: 5, line: 5,
column: 16, column: 16,
source: source }] source: source }]
elsif patch_url.match?(%r{macports/trunk}) elsif patch_url.include?("macports/trunk")
[{ message: [{ message:
<<~EOS.chomp, <<~EOS.chomp,
MacPorts patches should specify a revision instead of trunk: MacPorts patches should specify a revision instead of trunk: