Address all possible `Performance/StartWith` / `Performance/EndWith` violations

rubocop-performance v1.5.1 includes bug fixes for that cops.

https://github.com/rubocop-hq/rubocop-performance/releases/tag/v1.5.1
This commit is contained in:
Ryuta Kamizono 2019-11-14 03:20:29 +09:00
parent 081dfef95a
commit ad767034c9
10 changed files with 15 additions and 15 deletions

View File

@ -284,8 +284,8 @@ GEM
image_processing (1.9.3) image_processing (1.9.3)
mini_magick (>= 4.9.5, < 5) mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.13, < 3) ruby-vips (>= 2.0.13, < 3)
jaro_winkler (1.5.3) jaro_winkler (1.5.4)
jaro_winkler (1.5.3-java) jaro_winkler (1.5.4-java)
jdbc-mysql (5.1.47) jdbc-mysql (5.1.47)
jdbc-postgres (42.2.6) jdbc-postgres (42.2.6)
jdbc-sqlite3 (3.28.0) jdbc-sqlite3 (3.28.0)
@ -349,7 +349,7 @@ GEM
nokogiri (1.10.4-x86-mingw32) nokogiri (1.10.4-x86-mingw32)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
os (1.0.1) os (1.0.1)
parallel (1.18.0) parallel (1.19.0)
parser (2.6.5.0) parser (2.6.5.0)
ast (~> 2.4.0) ast (~> 2.4.0)
path_expander (1.1.0) path_expander (1.1.0)
@ -416,7 +416,7 @@ GEM
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7) unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.5.0) rubocop-performance (1.5.1)
rubocop (>= 0.71.0) rubocop (>= 0.71.0)
rubocop-rails (2.3.2) rubocop-rails (2.3.2)
rack (>= 1.1) rack (>= 1.1)

View File

@ -482,7 +482,7 @@ module ActionController
def raw_params(auth) def raw_params(auth)
_raw_params = auth.sub(TOKEN_REGEX, "").split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/) _raw_params = auth.sub(TOKEN_REGEX, "").split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
if !(%r{\A#{TOKEN_KEY}}.match?(_raw_params.first)) if !_raw_params.first.start_with?(TOKEN_KEY)
_raw_params[0] = "#{TOKEN_KEY}#{_raw_params.first}" _raw_params[0] = "#{TOKEN_KEY}#{_raw_params.first}"
end end

View File

@ -594,8 +594,9 @@ module ActionController
private private
def scrub_env!(env) def scrub_env!(env)
env.delete_if { |k, v| k.match?(/^(action_dispatch|rack)\.request/) } env.delete_if do |k, _|
env.delete_if { |k, v| k.match?(/^action_dispatch\.rescue/) } k.start_with?("rack.request", "action_dispatch.request", "action_dispatch.rescue")
end
env["rack.input"] = StringIO.new env["rack.input"] = StringIO.new
env.delete "CONTENT_LENGTH" env.delete "CONTENT_LENGTH"
env.delete "RAW_POST_DATA" env.delete "RAW_POST_DATA"

View File

@ -21,7 +21,7 @@ module ActionDispatch
setup do setup do
@cleaner = ActiveSupport::BacktraceCleaner.new @cleaner = ActiveSupport::BacktraceCleaner.new
@cleaner.remove_filters! @cleaner.remove_filters!
@cleaner.add_silencer { |line| !line.match?(/^lib/) } @cleaner.add_silencer { |line| !line.start_with?("lib") }
end end
test "#source_extracts fetches source fragments for every backtrace entry" do test "#source_extracts fetches source fragments for every backtrace entry" do

View File

@ -11,7 +11,7 @@ module ActiveRecord
end end
def case_sensitive? def case_sensitive?
collation && !/_ci\z/.match?(collation) collation && !collation.end_with?("_ci")
end end
def auto_increment? def auto_increment?

View File

@ -415,8 +415,7 @@ module ActiveRecord
@content_columns ||= columns.reject do |c| @content_columns ||= columns.reject do |c|
c.name == primary_key || c.name == primary_key ||
c.name == inheritance_column || c.name == inheritance_column ||
c.name.end_with?("_id") || c.name.end_with?("_id", "_count")
c.name.end_with?("_count")
end end
end end

View File

@ -5,7 +5,7 @@ require "active_support/core_ext/hash/deep_merge"
module ActiveSupport module ActiveSupport
class OptionMerger #:nodoc: class OptionMerger #:nodoc:
instance_methods.each do |method| instance_methods.each do |method|
undef_method(method) unless method.match?(/^(__|instance_eval|class|object_id)/) undef_method(method) unless method.start_with?("__", "instance_eval", "class", "object_id")
end end
def initialize(context, options) def initialize(context, options)

View File

@ -44,7 +44,7 @@ class CodeStatistics #:nodoc:
Dir.foreach(directory) do |file_name| Dir.foreach(directory) do |file_name|
path = "#{directory}/#{file_name}" path = "#{directory}/#{file_name}"
if File.directory?(path) && !(/^\./.match?(file_name)) if File.directory?(path) && !file_name.start_with?(".")
stats.add(calculate_directory_statistics(path, pattern)) stats.add(calculate_directory_statistics(path, pattern))
elsif file_name&.match?(pattern) elsif file_name&.match?(pattern)
stats.add_by_file_path(path) stats.add_by_file_path(path)

View File

@ -52,7 +52,7 @@ module Rails
def inherited(base) #:nodoc: def inherited(base) #:nodoc:
super super
if base.name && !base.name.match?(/Base$/) if base.name && !base.name.end_with?("Base")
Rails::Command.subclasses << base Rails::Command.subclasses << base
end end
end end

View File

@ -233,7 +233,7 @@ module Rails
# Invoke source_root so the default_source_root is set. # Invoke source_root so the default_source_root is set.
base.source_root base.source_root
if base.name && !base.name.match?(/Base$/) if base.name && !base.name.end_with?("Base")
Rails::Generators.subclasses << base Rails::Generators.subclasses << base
Rails::Generators.templates_path.each do |path| Rails::Generators.templates_path.each do |path|