mirror of https://github.com/rails/rails
Use RuboCop Performance 1.16.0
## Summary This PR bumps RuboCop Performance to 1.16.0 and suppresses the following new offenses: ```console % bundle exec rubocop (snip) Offenses: actionpack/lib/action_dispatch/routing/mapper.rb:309:16: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if /#/.match?(to) ^^^^^^^^^^^^^^ actionpack/lib/action_dispatch/routing/mapper.rb:1643:18: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if /#/.match?(to) ^^^^^^^^^^^^^^ actionpack/lib/action_dispatch/routing/route_set.rb:887:67: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. path = Journey::Router::Utils.normalize_path(path) unless %r{://}.match?(path) ^^^^^^^^^^^^^^^^^^^^ actionpack/lib/action_dispatch/testing/assertions/routing.rb:86:12: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if %r{://}.match?(expected_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ actionpack/lib/action_dispatch/testing/assertions/routing.rb:205:14: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if %r{://}.match?(path) ^^^^^^^^^^^^^^^^^^^^ actionpack/lib/action_dispatch/testing/integration.rb:235:12: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if %r{://}.match?(path) ^^^^^^^^^^^^^^^^^^^^ actiontext/bin/webpack:18:6: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 150)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ actiontext/bin/webpack-dev-server:18:6: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 150)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb:120:64: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. elsif column.type == :uuid && value.is_a?(String) && /\(\)/.match?(value) ^^^^^^^^^^^^^^^^^^^^ railties/lib/rails/commands/secrets/secrets_command.rb:28:12: C: [Correctable] Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern. if /secrets\.yml\.enc/.match?(error.message) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3088 files inspected, 10 offenses detected, 10 offenses autocorrectable ``` ## Additional Information This behavior change is based on: https://github.com/rubocop/rubocop-performance/pull/332
This commit is contained in:
parent
fee259b381
commit
5726b1d1d7
|
@ -410,7 +410,7 @@ GEM
|
|||
rubocop (>= 0.90, < 2.0)
|
||||
rubocop-packaging (0.5.2)
|
||||
rubocop (>= 1.33, < 2.0)
|
||||
rubocop-performance (1.15.2)
|
||||
rubocop-performance (1.16.0)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.17.4)
|
||||
|
|
|
@ -306,7 +306,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
def split_to(to)
|
||||
if /#/.match?(to)
|
||||
if to&.include?("#")
|
||||
to.split("#").map!(&:-@)
|
||||
else
|
||||
[]
|
||||
|
@ -1640,7 +1640,7 @@ module ActionDispatch
|
|||
when Symbol
|
||||
options[:action] = to
|
||||
when String
|
||||
if /#/.match?(to)
|
||||
if to.include?("#")
|
||||
options[:to] = to
|
||||
else
|
||||
options[:controller] = to
|
||||
|
|
|
@ -884,7 +884,7 @@ module ActionDispatch
|
|||
|
||||
def recognize_path(path, environment = {})
|
||||
method = (environment[:method] || "GET").to_s.upcase
|
||||
path = Journey::Router::Utils.normalize_path(path) unless %r{://}.match?(path)
|
||||
path = Journey::Router::Utils.normalize_path(path) unless path.include?("://")
|
||||
extras = environment[:extras] || {}
|
||||
|
||||
begin
|
||||
|
|
|
@ -83,7 +83,7 @@ module ActionDispatch
|
|||
# # Asserts that the generated route gives us our custom route
|
||||
# assert_generates "changesets/12", { controller: 'scm', action: 'show_diff', revision: "12" }
|
||||
def assert_generates(expected_path, options, defaults = {}, extras = {}, message = nil)
|
||||
if %r{://}.match?(expected_path)
|
||||
if expected_path.include?("://")
|
||||
fail_on(URI::InvalidURIError, message) do
|
||||
uri = URI.parse(expected_path)
|
||||
expected_path = uri.path.to_s.empty? ? "/" : uri.path
|
||||
|
@ -202,7 +202,7 @@ module ActionDispatch
|
|||
controller = @controller if defined?(@controller)
|
||||
request = ActionController::TestRequest.create controller&.class
|
||||
|
||||
if %r{://}.match?(path)
|
||||
if path.include?("://")
|
||||
fail_on(URI::InvalidURIError, msg) do
|
||||
uri = URI.parse(path)
|
||||
request.env["rack.url_scheme"] = uri.scheme || "http"
|
||||
|
|
|
@ -232,7 +232,7 @@ module ActionDispatch
|
|||
method = :post
|
||||
end
|
||||
|
||||
if %r{://}.match?(path)
|
||||
if path.include?("://")
|
||||
path = build_expanded_path(path) do |location|
|
||||
https! URI::HTTPS === location if location.scheme
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|||
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 150))
|
||||
if File.read(bundle_binstub, 150).include?("This file was generated by Bundler")
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
|
|
|
@ -15,7 +15,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|||
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 150))
|
||||
if File.read(bundle_binstub, 150).include?("This file was generated by Bundler")
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
|
|
|
@ -117,7 +117,7 @@ module ActiveRecord
|
|||
def quote_default_expression(value, column) # :nodoc:
|
||||
if value.is_a?(Proc)
|
||||
value.call
|
||||
elsif column.type == :uuid && value.is_a?(String) && /\(\)/.match?(value)
|
||||
elsif column.type == :uuid && value.is_a?(String) && value.include?("()")
|
||||
value # Does not quote function default values for UUID columns
|
||||
elsif column.respond_to?(:array?)
|
||||
type = lookup_cast_type_from_column(column)
|
||||
|
|
|
@ -25,7 +25,7 @@ module Rails
|
|||
rescue Rails::Secrets::MissingKeyError => error
|
||||
say error.message
|
||||
rescue Errno::ENOENT => error
|
||||
if /secrets\.yml\.enc/.match?(error.message)
|
||||
if error.message.include?("secrets.yml.enc")
|
||||
deprecate_in_favor_of_credentials_and_exit
|
||||
else
|
||||
raise
|
||||
|
|
Loading…
Reference in New Issue