Skip to content

Commit

Permalink
Fix brew style.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Jul 7, 2020
1 parent d2e2298 commit fa760a2
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def check_coretap_git_branch
return if !Utils.git_available? || !(coretap_path/".git").exist?

branch = coretap_path.git_branch
return if branch.nil? || branch =~ /master/
return if branch.blank? || branch.include?("master")

<<~EOS
#{CoreTap.instance.full_name} is not on the master branch.
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/extend/os/mac/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def check_xcode_select_path
def check_xcode_license_approved
# If the user installs Xcode-only, they have to approve the
# 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
You have not agreed to the Xcode license.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/language/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def pip_install(targets)

t.stage { do_install Pathname.pwd }
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
end
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/requirements/java_requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def version_without_plus
end

def exact_version?
@version && @version.to_s.chars.last != "+"
@version && @version.to_s[-1] != "+"
end

def fits_latest?
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/rubocops/formula_desc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)

# Check if command-line is wrongly used in formula's desc
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}\""
end

Expand Down Expand Up @@ -86,7 +86,7 @@ def autocorrect(node)
correction = node.source
first_word = string_content(node).split.first
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
end
correction.sub!(/^(['"]?)an?\s/i, "\\1")
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/rubocops/homepage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
# https://wiki.freedesktop.org/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/)?}
if homepage =~ /Software/
if homepage.include?("Software")
problem "#{homepage} should be styled `https://wiki.freedesktop.org/www/Software/project_name`"
else
problem "#{homepage} should be styled `https://wiki.freedesktop.org/project_name`"
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/rubocops/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
# Don't use GitHub .zip files
zip_gh_pattern = %r{https://.*github.*/(archive|releases)/.*\.zip$}
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})."
end
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/rubocops/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class #{name.capitalize} < Formula
RUBY

inspect_source(source)
if homepage.match?(%r{http://www\.freedesktop\.org})
if homepage.match?(/Software/)
if homepage.include?("http://www.freedesktop.org")
if homepage.include?("Software")
expected_offenses = [{ message: "#{homepage} should be styled " \
"`https://wiki.freedesktop.org/www/Software/project_name`",
severity: :convention,
Expand All @@ -89,7 +89,7 @@ class #{name.capitalize} < Formula
column: 2,
source: source }]
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",
severity: :convention,
line: 2,
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/test/rubocops/patches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def patches
EOS

inspect_source(source)
expected_offense = if patch_url.match?(%r{/raw\.github\.com/})
expected_offense = if patch_url.include?("/raw.github.com/")
[{ message:
<<~EOS.chomp,
GitHub/Gist patches should specify a revision:
Expand All @@ -58,7 +58,7 @@ def patches
line: 5,
column: 12,
source: source }]
elsif patch_url.match?(%r{macports/trunk})
elsif patch_url.include?("macports/trunk")
[{ message:
<<~EOS.chomp,
MacPorts patches should specify a revision instead of trunk:
Expand Down Expand Up @@ -232,7 +232,7 @@ class Foo < Formula
RUBY

inspect_source(source)
expected_offense = if patch_url.match?(%r{/raw\.github\.com/})
expected_offense = if patch_url.include?("/raw.github.com/")
[{ message:
<<~EOS.chomp,
GitHub/Gist patches should specify a revision:
Expand All @@ -242,7 +242,7 @@ class Foo < Formula
line: 5,
column: 16,
source: source }]
elsif patch_url.match?(%r{macports/trunk})
elsif patch_url.include?("macports/trunk")
[{ message:
<<~EOS.chomp,
MacPorts patches should specify a revision instead of trunk:
Expand Down

0 comments on commit fa760a2

Please sign in to comment.