Update Gems.

This commit is contained in:
Markus Reiter 2019-10-03 08:50:45 +02:00
parent 62f5e8f611
commit b1d0c61fea
55 changed files with 106 additions and 102 deletions

View File

@ -45,9 +45,10 @@ Style/BarePercentLiterals:
Style/CollectionMethods:
Enabled: true
# Prefer simple tokens without type annotations.
# Prefer tokens with type annotations for consistency
# between formatting numbers and strings.
Style/FormatStringToken:
EnforcedStyle: template
EnforcedStyle: annotated
# This shouldn't be enabled until LineLength is lower.
Style/IfUnlessModifier:

View File

@ -3,7 +3,7 @@
source "https://rubygems.org"
# installed gems
gem "coveralls", require: false
gem "coveralls", "~> 0.8", require: false
gem "parallel_tests"
gem "ronn", require: false
gem "rspec"
@ -12,7 +12,6 @@ gem "rspec-retry", require: false
gem "rspec-wait", require: false
gem "rubocop"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
# vendored gems
gem "activesupport"

View File

@ -66,7 +66,7 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
rspec-expectations (3.8.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-its (1.3.0)
@ -80,14 +80,14 @@ GEM
rspec-support (3.8.3)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
rubocop (0.74.0)
rubocop (0.75.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.4.1)
rubocop-performance (1.5.0)
rubocop (>= 0.71.0)
rubocop-rspec (1.36.0)
rubocop (>= 0.68.1)
@ -97,8 +97,6 @@ GEM
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-cobertura (1.3.1)
simplecov (~> 0.8)
simplecov-html (0.10.2)
term-ansicolor (1.7.1)
tins (~> 1.0)
@ -120,7 +118,7 @@ DEPENDENCIES
activesupport
backports
concurrent-ruby
coveralls
coveralls (~> 0.8)
mechanize
parallel_tests
plist
@ -134,7 +132,6 @@ DEPENDENCIES
rubocop-rspec
ruby-macho
simplecov
simplecov-cobertura
BUNDLED WITH
2.0.1
2.0.2

View File

@ -410,6 +410,6 @@ module Homebrew
end
def format_percent(percent)
format "%.2f", percent
format("%<percent>.2f", percent: percent)
end
end

View File

@ -88,7 +88,7 @@ module Debrew
def self.debrew
@active = true
Object.send(:include, Raise)
Object.include Raise
begin
yield

View File

@ -254,7 +254,7 @@ module Homebrew
wanted_mode = 0100644 & ~File.umask
actual_mode = formula.path.stat.mode
unless actual_mode == wanted_mode
problem format("Incorrect file permissions (%03<actual>o): chmod %03<wanted>o %{path}",
problem format("Incorrect file permissions (%03<actual>o): chmod %03<wanted>o %<path>s",
actual: actual_mode & 0777,
wanted: wanted_mode & 0777,
path: formula.path)

View File

@ -530,14 +530,13 @@ module Homebrew
unless args.no_commit?
if ENV["HOMEBREW_GIT_NAME"]
ENV["GIT_AUTHOR_NAME"] =
ENV["GIT_COMMITTER_NAME"] =
ENV["HOMEBREW_GIT_NAME"]
ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] =
ENV["HOMEBREW_GIT_NAME"]
end
if ENV["HOMEBREW_GIT_EMAIL"]
ENV["GIT_AUTHOR_EMAIL"] =
ENV["GIT_COMMITTER_EMAIL"] =
ENV["HOMEBREW_GIT_EMAIL"]
ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"] =
ENV["HOMEBREW_GIT_EMAIL"]
end
short_name = formula_name.split("/", -1).last

View File

@ -1843,7 +1843,7 @@ class Formula
@exec_count ||= 0
@exec_count += 1
logfn = format("#{logs}/#{active_log_prefix}%02<exec_count>d.%{cmd_base}",
logfn = format("#{logs}/#{active_log_prefix}%02<exec_count>d.%<cmd_base>s",
exec_count: @exec_count,
cmd_base: File.basename(cmd).split(" ").first)
logs.mkpath

View File

@ -40,7 +40,7 @@ class Messages
oh1 "Installation times"
install_times.each do |t|
puts format("%-20s %10.3f s", t[:formula], t[:time])
puts format("%<formula>-20s %<time>10.3f s", t)
end
end
end

View File

@ -19,15 +19,15 @@ module RuboCop
COMMENT_FORMAT = /# [^ ]+ was verified as official when first introduced to the cask/.freeze
MSG_NO_MATCH = "`%{url}` does not match `%{full_url}`"
MSG_NO_MATCH = "`%<url>s` does not match `%<full_url>s`"
MSG_MISSING = ("`%{domain}` does not match `%{homepage}`, a comment has to be added " \
MSG_MISSING = ("`%<domain>s` does not match `%<homepage>s`, a comment has to be added " \
"above the `url` stanza. For details, see " + REFERENCE_URL).freeze
MSG_WRONG_FORMAT = ("`%{comment}` does not match the expected comment format. " \
MSG_WRONG_FORMAT = ("`%<comment>s` does not match the expected comment format. " \
"For details, see " + REFERENCE_URL).freeze
MSG_UNNECESSARY = "The URL's domain `%{domain}` matches the homepage `%{homepage}`, " \
MSG_UNNECESSARY = "The URL's domain `%<domain>s` matches the homepage `%<homepage>s`, " \
"the comment above the `url` stanza is unnecessary"
def on_cask(cask_block)

View File

@ -11,7 +11,7 @@ module RuboCop
class HomepageUrlTrailingSlash < Cop
include OnHomepageStanza
MSG_NO_SLASH = "'%{url}' must have a slash after the domain."
MSG_NO_SLASH = "'%<url>s' must have a slash after the domain."
def on_homepage_stanza(stanza)
url_node = stanza.stanza_node.first_argument

View File

@ -21,7 +21,7 @@ module RuboCop
extend Forwardable
include CaskHelp
MESSAGE = "Use `%{preferred}` instead of `%{current}`"
MESSAGE = "Use `%<preferred>s` instead of `%<current>s`"
def on_cask(cask_block)
@cask_header = cask_block.header

View File

@ -12,7 +12,7 @@ module RuboCop
extend Forwardable
include CaskHelp
MESSAGE = "`%{stanza}` stanza out of order"
MESSAGE = "`%<stanza>s` stanza out of order"
def on_cask(cask_block)
@cask_block = cask_block

View File

@ -5,10 +5,8 @@ describe Cask::Artifact::App, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-alt-target")) }
let(:install_phase) {
lambda do
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
}
@ -23,7 +21,7 @@ describe Cask::Artifact::App, :cask do
expect(source_path).to be_a_directory
expect(target_path).not_to exist
install_phase.call
install_phase
expect(target_path).to be_a_directory
expect(source_path).not_to exist
@ -44,7 +42,7 @@ describe Cask::Artifact::App, :cask do
appsubdir = cask.staged_path.join("subdir").tap(&:mkpath)
FileUtils.mv(source_path, appsubdir)
install_phase.call
install_phase
expect(target_path).to be_a_directory
expect(appsubdir.join("Caffeine.app")).not_to exist
@ -55,7 +53,7 @@ describe Cask::Artifact::App, :cask do
staged_app_copy = source_path.sub("Caffeine.app", "Caffeine Deluxe.app")
FileUtils.cp_r source_path, staged_app_copy
install_phase.call
install_phase
expect(target_path).to be_a_directory
expect(source_path).not_to exist
@ -67,7 +65,8 @@ describe Cask::Artifact::App, :cask do
it "avoids clobbering an existing app by moving over it" do
target_path.mkpath
expect(install_phase).to raise_error(Cask::CaskError, "It seems there is already an App at '#{target_path}'.")
expect { install_phase }
.to raise_error(Cask::CaskError, "It seems there is already an App at '#{target_path}'.")
expect(source_path).to be_a_directory
expect(target_path).to be_a_directory

View File

@ -5,10 +5,8 @@ describe Cask::Artifact::App, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-two-apps-correct")) }
let(:install_phase) {
lambda do
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
}
@ -23,7 +21,7 @@ describe Cask::Artifact::App, :cask do
end
it "installs both apps using the proper target directory" do
install_phase.call
install_phase
expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist
@ -36,7 +34,7 @@ describe Cask::Artifact::App, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-two-apps-subdir")) }
it "installs both apps using the proper target directory" do
install_phase.call
install_phase
expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist
@ -49,7 +47,7 @@ describe Cask::Artifact::App, :cask do
it "only uses apps when they are specified" do
FileUtils.cp_r source_path_mini, source_path_mini.sub("Caffeine Mini.app", "Caffeine Deluxe.app")
install_phase.call
install_phase
expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist
@ -63,7 +61,7 @@ describe Cask::Artifact::App, :cask do
target_path_mini.mkpath
expect {
expect(install_phase).to output(<<~EOS).to_stdout
expect { install_phase }.to output(<<~EOS).to_stdout
==> Moving App 'Caffeine Pro.app' to '#{target_path_pro}'
EOS
}.to raise_error(Cask::CaskError, "It seems there is already an App at '#{target_path_mini}'.")
@ -77,7 +75,7 @@ describe Cask::Artifact::App, :cask do
target_path_pro.mkpath
expect {
expect(install_phase).to output(<<~EOS).to_stdout
expect { install_phase }.to output(<<~EOS).to_stdout
==> Moving App 'Caffeine Mini.app' to '#{target_path_mini}'
EOS
}.to raise_error(Cask::CaskError, "It seems there is already an App at '#{target_path_pro}'.")

View File

@ -3,10 +3,8 @@
# TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb
describe "Satisfy Dependencies and Requirements", :cask do
subject {
lambda do
Cask::Installer.new(cask).install
end
subject(:install) {
Cask::Installer.new(cask).install
}
describe "depends_on cask" do
@ -14,7 +12,7 @@ describe "Satisfy Dependencies and Requirements", :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask")) }
it "installs the dependency of a Cask and the Cask itself" do
expect(subject).not_to raise_error
expect { install }.not_to raise_error
expect(cask).to be_installed
expect(dependency).to be_installed
end
@ -23,7 +21,7 @@ describe "Satisfy Dependencies and Requirements", :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-cask-cyclic")) }
it {
expect(subject).to raise_error(
expect { install }.to raise_error(
Cask::CaskCyclicDependencyError,
"Cask 'with-depends-on-cask-cyclic' includes cyclic dependencies "\
"on other Casks: with-depends-on-cask-cyclic-helper",
@ -36,31 +34,41 @@ describe "Satisfy Dependencies and Requirements", :cask do
context "given an array" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-macos-array")) }
it { is_expected.not_to raise_error }
it "does not raise an error" do
expect { install }.not_to raise_error
end
end
context "given a comparison" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-macos-comparison")) }
it { is_expected.not_to raise_error }
it "does not raise an error" do
expect { install }.not_to raise_error
end
end
context "given a string", :needs_compat do
let(:cask) { Cask::CaskLoader.load(cask_path("compat/with-depends-on-macos-string")) }
it { is_expected.not_to raise_error }
it "does not raise an error" do
expect { install }.not_to raise_error
end
end
context "given a symbol" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-macos-symbol")) }
it { is_expected.not_to raise_error }
it "does not raise an error" do
expect { install }.not_to raise_error
end
end
context "when not satisfied" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-macos-failure")) }
it { is_expected.to raise_error(Cask::CaskError) }
it "raises an error" do
expect { install }.to raise_error(Cask::CaskError)
end
end
end
@ -68,7 +76,9 @@ describe "Satisfy Dependencies and Requirements", :cask do
context "when satisfied" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-arch")) }
it { is_expected.not_to raise_error }
it "does not raise an error" do
expect { install }.not_to raise_error
end
end
end
@ -81,21 +91,27 @@ describe "Satisfy Dependencies and Requirements", :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-x11")) }
let(:x11_installed) { true }
it { is_expected.not_to raise_error }
it "does not raise an error" do
expect { install }.not_to raise_error
end
end
context "when not satisfied" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-x11")) }
let(:x11_installed) { false }
it { is_expected.to raise_error(Cask::CaskX11DependencyError) }
it "does not raise an error" do
expect { install }.to raise_error Cask::CaskX11DependencyError
end
end
context "when depends_on x11: false" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-depends-on-x11-false")) }
let(:x11_installed) { false }
it { is_expected.not_to raise_error }
it "does not raise an error" do
expect { install }.not_to raise_error
end
end
end
end

View File

@ -14,10 +14,8 @@ describe Cask::DSL, :cask do
describe "when a Cask includes an unknown method" do
let(:attempt_unknown_method) {
lambda do
Cask::Cask.new("unexpected-method-cask") do
future_feature :not_yet_on_your_machine
end
Cask::Cask.new("unexpected-method-cask") do
future_feature :not_yet_on_your_machine
end
}
@ -32,13 +30,13 @@ describe Cask::DSL, :cask do
EOS
expect {
expect(attempt_unknown_method).not_to output.to_stdout
expect { attempt_unknown_method }.not_to output.to_stdout
}.to output(expected).to_stderr
end
it "will simply warn, not throw an exception" do
expect {
attempt_unknown_method.call
attempt_unknown_method
}.not_to raise_error
end
end

View File

@ -94,9 +94,8 @@ describe Homebrew::Diagnostic::Checks do
file = "#{path}/foo-config"
FileUtils.touch file
FileUtils.chmod 0755, file
ENV["HOMEBREW_PATH"] =
ENV["PATH"] =
"#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
ENV["HOMEBREW_PATH"] = ENV["PATH"] =
"#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
expect(subject.check_for_config_scripts)
.to match('"config" scripts exist')

View File

@ -150,7 +150,7 @@ describe RuboCop::Cop::Cask::StanzaGrouping do
url 'https://foo.brew.sh/foo.zip'
name 'Foo'
app 'Foo.app'
%{caveats}
%<caveats>s
end
CASK
end
@ -165,7 +165,7 @@ describe RuboCop::Cop::Cask::StanzaGrouping do
app 'Foo.app'
%{caveats}
%<caveats>s
end
CASK
end

View File

@ -202,7 +202,7 @@ describe RuboCop::Cop::Cask::StanzaOrder do
cask 'foo' do
name 'Foo'
url 'https://foo.brew.sh/foo.zip'
%{caveats}
%<caveats>s
version :latest
app 'Foo.app'
sha256 :no_check
@ -217,7 +217,7 @@ describe RuboCop::Cop::Cask::StanzaOrder do
url 'https://foo.brew.sh/foo.zip'
name 'Foo'
app 'Foo.app'
%{caveats}
%<caveats>s
end
CASK
end

View File

@ -67,7 +67,7 @@ module Homebrew
at_exit do
col_width = [$times.keys.map(&:size).max.to_i + 2, 15].max
$times.sort_by { |_k, v| v }.each do |method, time|
puts format("%-*s %0.4f sec", col_width, "#{method}:", time)
puts format("%<method>-#{col_width}s %<time>0.4f sec", method: "#{method}:", time: time)
end
end
end
@ -415,7 +415,7 @@ module Kernel
if ((size * 10).to_i % 10).zero?
"#{size.to_i}#{unit}"
else
"#{format("%.1f", size)}#{unit}"
"#{format("%<size>.1f", size: size)}#{unit}"
end
end

View File

@ -60,7 +60,7 @@ def curl_download(*args, to: nil, **options)
range_stdout = curl_output("--location", "--range", "0-1",
"--dump-header", "-",
"--write-out", "%{http_code}",
"--write-out", "%\{http_code}",
"--output", "/dev/null", *args, **options).stdout
headers, _, http_status = range_stdout.partition("\r\n\r\n")

View File

@ -163,7 +163,7 @@ module GitHub
# This is a no-op if the user is opting out of using the GitHub API.
return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"]
args = ["--header", "Accept: application/vnd.github.v3+json", "--write-out", "\n%{http_code}"]
args = ["--header", "Accept: application/vnd.github.v3+json", "--write-out", "\n%\{http_code}"]
args += ["--header", "Accept: application/vnd.github.antiope-preview+json"]
token, username = api_credentials

View File

@ -5,7 +5,7 @@ ruby_version = RbConfig::CONFIG["ruby_version"]
path = File.expand_path('..', __FILE__)
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/concurrent-ruby-1.1.5/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.6.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.12.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.12.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thread_safe-0.3.6/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tzinfo-1.2.5/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/activesupport-5.2.3/lib"
@ -45,24 +45,23 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mechanize-2.7.6/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mustache-1.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.17.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-2.29.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.6.4.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.6.5.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-18/2.3.0/rdiscount-2.2.0.1"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rdiscount-2.2.0.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ronn-0.7.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-support-3.8.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-support-3.8.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-core-3.8.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-expectations-3.8.4/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-mocks-3.8.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-expectations-3.8.5/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-mocks-3.8.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-3.8.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-its-1.3.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-retry-0.6.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.6.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.74.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.4.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.75.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.5.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.36.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-cobertura-1.3.1/lib"

View File

@ -44,11 +44,10 @@ Performance/Count:
# This cop has known compatibility issues with `ActiveRecord` and other
# frameworks. ActiveRecord's `count` ignores the block that is passed to it.
# For more information, see the documentation in the cop itself.
# If you understand the known risk, you can disable `SafeMode`.
SafeMode: true
SafeAutoCorrect: false
Enabled: true
VersionAdded: '0.31'
VersionChanged: '0.39'
VersionChanged: '1.5'
Performance/Detect:
Description: >-
@ -59,10 +58,10 @@ Performance/Detect:
# frameworks. `ActiveRecord` does not implement a `detect` method and `find`
# has its own meaning. Correcting `ActiveRecord` methods with this cop
# should be considered unsafe.
SafeMode: true
SafeAutoCorrect: false
Enabled: true
VersionAdded: '0.30'
VersionChanged: '0.39'
VersionChanged: '1.5'
Performance/DoubleStartEndWith:
Description: >-

View File

@ -38,7 +38,6 @@ module RuboCop
#
# Model.where(id: [1, 2, 3]).to_a.count { |m| m.method == true }
class Count < Cop
include SafeMode
include RangeHelp
MSG = 'Use `count` instead of `%<selector>s...%<counter>s`.'
@ -51,8 +50,6 @@ module RuboCop
PATTERN
def on_send(node)
return if rails_safe_mode?
count_candidate?(node) do |selector_node, selector, counter|
return unless eligible_node?(node)

View File

@ -23,8 +23,6 @@ module RuboCop
# own meaning. Correcting ActiveRecord methods with this cop should be
# considered unsafe.
class Detect < Cop
include SafeMode
MSG = 'Use `%<prefer>s` instead of ' \
'`%<first_method>s.%<second_method>s`.'
REVERSE_MSG = 'Use `reverse.%<prefer>s` instead of ' \
@ -38,8 +36,6 @@ module RuboCop
PATTERN
def on_send(node)
return if rails_safe_mode?
detect_candidate?(node) do |receiver, second_method, args|
return unless args.empty?
return unless receiver

View File

@ -23,7 +23,14 @@ module RuboCop
'multiple levels.'
def_node_matcher :flat_map_candidate?, <<-PATTERN
(send (block $(send _ ${:collect :map}) ...) ${:flatten :flatten!} $...)
(send
{
(block $(send _ ${:collect :map}) ...)
$(send _ ${:collect :map} (block_pass _))
}
${:flatten :flatten!}
$...
)
PATTERN
def on_send(node)

View File

@ -132,7 +132,7 @@ module RuboCop
end
def max_key_value_pairs
Integer(cop_config['MaxKeyValuePairs']) || 2
Integer(cop_config['MaxKeyValuePairs'] || 2)
end
# A utility class for checking the use of values within an