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

build(deps): bump rubocop-performance from 1.6.1 to 1.7.0 in /Library/Homebrew #7928

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
4 changes: 2 additions & 2 deletions Library/Homebrew/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ GEM
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.1.0)
parser (>= 2.7.0.1)
rubocop-performance (1.6.1)
rubocop (>= 0.71.0)
rubocop-performance (1.7.0)
rubocop (>= 0.82.0)
rubocop-rspec (1.41.0)
rubocop (>= 0.68.1)
ruby-macho (2.2.0)
Expand Down
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
2 changes: 1 addition & 1 deletion Library/Homebrew/vendor/bundle/bundler/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.7.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.87.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.6.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.7.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.41.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# This is the default configuration file.

Performance/AncestorsInclude:
Description: 'Use `A <= B` instead of `A.ancestors.include?(B)`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#ancestorsinclude-vs--code'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/BigDecimalWithNumericArgument:
Description: 'Convert numeric argument to string before passing to BigDecimal.'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/BindCall:
Description: 'Use `bind_call(obj, args, ...)` instead of `bind(obj).call(args, ...)`.'
Enabled: true
Expand Down Expand Up @@ -131,17 +142,24 @@ Performance/InefficientHashSearch:
VersionAdded: '0.56'
Safe: false

Performance/IoReadlines:
Description: 'Use `IO.each_line` (`IO#each_line`) instead of `IO.readlines` (`IO#readlines`).'
Reference: 'https://docs.gitlab.com/ee/development/performance.html#reading-from-files-and-other-data-sources'
Enabled: false
VersionAdded: '1.7'

Performance/OpenStruct:
Description: 'Use `Struct` instead of `OpenStruct`.'
Enabled: false
VersionAdded: '0.61'
Safe: false

Performance/RangeInclude:
Description: 'Use `Range#cover?` instead of `Range#include?`.'
Description: 'Use `Range#cover?` instead of `Range#include?` (or `Range#member?`).'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
Enabled: true
VersionAdded: '0.36'
VersionChanged: '1.7'
Safe: false

Performance/RedundantBlockCall:
Expand All @@ -165,6 +183,16 @@ Performance/RedundantMerge:
# Max number of key-value pairs to consider an offense
MaxKeyValuePairs: 2

Performance/RedundantSortBlock:
Description: 'Use `sort` instead of `sort { |a, b| a <=> b }`.'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/RedundantStringChars:
Description: 'Checks for redundant `String#chars`.'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/RegexpMatch:
Description: >-
Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
Expand All @@ -179,6 +207,11 @@ Performance/ReverseEach:
Enabled: true
VersionAdded: '0.30'

Performance/ReverseFirst:
Description: 'Use `last(n).reverse` instead of `reverse.first(n)`.'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/Size:
Description: >-
Use `size` instead of `count` for counting
Expand All @@ -187,6 +220,17 @@ Performance/Size:
Enabled: true
VersionAdded: '0.30'

Performance/SortReverse:
Description: 'Use `sort.reverse` instead of `sort { |a, b| b <=> a }`.'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/Squeeze:
Description: "Use `squeeze('a')` instead of `gsub(/a+/, 'a')`."
Reference: 'https://github.com/JuanitoFatas/fast-ruby#remove-extra-spaces-or-other-contiguous-characters-code'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/StartWith:
Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
Expand All @@ -200,6 +244,11 @@ Performance/StartWith:
VersionAdded: '0.36'
VersionChanged: '1.6'

Performance/StringInclude:
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
Enabled: 'pending'
VersionAdded: '1.7'

Performance/StringReplacement:
Description: >-
Use `tr` instead of `gsub` when you are replacing the same
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

module RuboCop
module Cop
# Common functionality for cops checking `Enumerable#sort` blocks.
module SortBlock
extend NodePattern::Macros
include RangeHelp

def_node_matcher :sort_with_block?, <<~PATTERN
(block
$(send _ :sort)
(args (arg $_a) (arg $_b))
$send)
PATTERN

def_node_matcher :replaceable_body?, <<~PATTERN
(send (lvar %1) :<=> (lvar %2))
PATTERN

private

def sort_range(send, node)
range_between(send.loc.selector.begin_pos, node.loc.end.end_pos)
end
end
end
end
Loading