From 989cc257360e1686287e5db8b56c522e58b21100 Mon Sep 17 00:00:00 2001 From: mishina Date: Mon, 30 May 2022 18:43:40 +0900 Subject: [PATCH 1/7] Upgrade RuboCop to the latest --- .rubocop.yml | 9 ++++++--- .rubocop_todo.yml | 4 ++-- Gemfile | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d41d8d923..a9478b791 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,16 +12,19 @@ AllCops: Layout/CaseIndentation: EnforcedStyle: end -Layout/IndentHash: +Layout/FirstHashElementIndentation: EnforcedStyle: consistent -Lint/EndAlignment: +Layout/EndAlignment: EnforcedStyleAlignWith: variable Style/TrailingCommaInArguments: EnforcedStyleForMultiline: consistent_comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: consistent_comma + +Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: consistent_comma Style/TrivialAccessors: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bc34785a7..f52e30cb8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -10,7 +10,7 @@ # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent -Layout/IndentHeredoc: +Layout/HeredocIndentation: Exclude: - 'support/ruby_enc_to_mysql.rb' - 'tasks/compile.rake' @@ -41,7 +41,7 @@ Metrics/CyclomaticComplexity: # Offense count: 313 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https -Metrics/LineLength: +Layout/LineLength: Max: 232 # Offense count: 6 diff --git a/Gemfile b/Gemfile index 6de48b0d1..ee1e1097c 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ group :test do # Downgrade psych because old RuboCop can't use new Psych gem 'psych', '< 4.0.0' # https://github.com/bbatsov/rubocop/pull/4789 - gem 'rubocop', '~> 0.50.0' + gem 'rubocop', '~> 1.30' end group :benchmarks, optional: true do From d238d7fb7f11aa1f7050eab28a31a2a91d256067 Mon Sep 17 00:00:00 2001 From: mishina Date: Mon, 30 May 2022 23:20:50 +0900 Subject: [PATCH 2/7] Install RuboCop only on Ruby 2.6+ Run RuboCop on Ruby 2.6 --- .github/workflows/rubocop.yml | 4 ++-- Gemfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 8a7725851..d66266dd6 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -9,10 +9,10 @@ jobs: BUNDLE_WITHOUT: development steps: - uses: actions/checkout@v3 - - name: Set up Ruby 2.4 + - name: Set up Ruby 2.6 uses: ruby/setup-ruby@v1 with: - ruby-version: 2.4 + ruby-version: 2.6 bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run RuboCop run: bundle exec rubocop diff --git a/Gemfile b/Gemfile index ee1e1097c..e6575bc1d 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ group :test do # Downgrade psych because old RuboCop can't use new Psych gem 'psych', '< 4.0.0' # https://github.com/bbatsov/rubocop/pull/4789 - gem 'rubocop', '~> 1.30' + gem 'rubocop', '~> 1.30' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') end group :benchmarks, optional: true do From a9517accd9627da2174828a14e52d4fae7ba8140 Mon Sep 17 00:00:00 2001 From: mishina Date: Mon, 30 May 2022 23:26:06 +0900 Subject: [PATCH 3/7] Fix some simple cops --- .rubocop.yml | 3 +++ Gemfile | 10 +++++----- benchmark/allocations.rb | 2 +- lib/mysql2.rb | 1 + lib/mysql2/client.rb | 4 ++++ spec/mysql2/client_spec.rb | 2 ++ spec/mysql2/result_spec.rb | 18 +++++++++--------- spec/mysql2/statement_spec.rb | 24 ++++++++++++------------ spec/spec_helper.rb | 3 ++- support/mysql_enc_to_ruby.rb | 2 +- 10 files changed, 40 insertions(+), 29 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a9478b791..74224c6b4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,6 +18,9 @@ Layout/FirstHashElementIndentation: Layout/EndAlignment: EnforcedStyleAlignWith: variable +Layout/HashAlignment: + EnforcedHashRocketStyle: table + Style/TrailingCommaInArguments: EnforcedStyleForMultiline: consistent_comma diff --git a/Gemfile b/Gemfile index e6575bc1d..96429bf8a 100644 --- a/Gemfile +++ b/Gemfile @@ -2,11 +2,11 @@ source 'https://rubygems.org' gemspec -gem 'rake', if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2") - '~> 13.0.1' - else - '< 13' - end +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2") + gem 'rake', '~> 13.0.1' +else + gem 'rake', '< 13' +end gem 'rake-compiler', '~> 1.1.0' # For local debugging, irb is Gemified since Ruby 2.6 diff --git a/benchmark/allocations.rb b/benchmark/allocations.rb index 7926a837d..cc6df4d18 100644 --- a/benchmark/allocations.rb +++ b/benchmark/allocations.rb @@ -16,7 +16,7 @@ def bench_allocations(feature, iterations = 10, batch_size = 1000) GC::Profiler.clear GC::Profiler.enable iterations.times { yield batch_size } - GC::Profiler.report(STDOUT) + GC::Profiler.report($stdout) GC::Profiler.disable end diff --git a/lib/mysql2.rb b/lib/mysql2.rb index e49060208..9461846e9 100644 --- a/lib/mysql2.rb +++ b/lib/mysql2.rb @@ -65,6 +65,7 @@ module Util # def self.key_hash_as_symbols(hash) return nil unless hash + Hash[hash.map { |k, v| [k.to_sym, v] }] end diff --git a/lib/mysql2/client.rb b/lib/mysql2/client.rb index 8a4a3e11b..582b6e305 100644 --- a/lib/mysql2/client.rb +++ b/lib/mysql2/client.rb @@ -20,6 +20,7 @@ def self.default_query_options def initialize(opts = {}) raise Mysql2::Error, "Options parameter must be a Hash" unless opts.is_a? Hash + opts = Mysql2::Util.key_hash_as_symbols(opts) @read_timeout = nil @query_options = self.class.default_query_options.dup @@ -33,6 +34,7 @@ def initialize(opts = {}) # TODO: stricter validation rather than silent massaging %i[reconnect connect_timeout local_infile read_timeout write_timeout default_file default_group secure_auth init_command automatic_close enable_cleartext_plugin default_auth].each do |key| next unless opts.key?(key) + case key when :reconnect, :local_infile, :secure_auth, :automatic_close, :enable_cleartext_plugin send(:"#{key}=", !!opts[key]) # rubocop:disable Style/DoubleNegation @@ -136,6 +138,7 @@ def find_default_ca_path # and performance_schema.session_account_connect_attrs def parse_connect_attrs(conn_attrs) return {} if Mysql2::Client::CONNECT_ATTRS.zero? + conn_attrs ||= {} conn_attrs[:program_name] ||= $PROGRAM_NAME conn_attrs.each_with_object({}) do |(key, value), hash| @@ -152,6 +155,7 @@ def query(sql, options = {}) def query_info info = query_info_string return {} unless info + info_hash = {} info.split.each_slice(2) { |s| info_hash[s[0].downcase.delete(':').to_sym] = s[1].to_i } info_hash diff --git a/spec/mysql2/client_spec.rb b/spec/mysql2/client_spec.rb index 5861882c6..2f757815e 100644 --- a/spec/mysql2/client_spec.rb +++ b/spec/mysql2/client_spec.rb @@ -54,6 +54,7 @@ Klient = Class.new(Mysql2::Client) do attr_reader :connect_args + def connect(*args) @connect_args ||= [] @connect_args << args @@ -212,6 +213,7 @@ def run_gc 10.times do closed = @client.query("SHOW PROCESSLIST").none? { |row| row['Id'] == connection_id } break if closed + sleep(0.1) end expect(closed).to eq(true) diff --git a/spec/mysql2/result_spec.rb b/spec/mysql2/result_spec.rb index 614cafc1a..ed3e9d262 100644 --- a/spec/mysql2/result_spec.rb +++ b/spec/mysql2/result_spec.rb @@ -497,17 +497,17 @@ end { - 'char_test' => 'CHAR', - 'varchar_test' => 'VARCHAR', - 'varbinary_test' => 'VARBINARY', - 'tiny_blob_test' => 'TINYBLOB', - 'tiny_text_test' => 'TINYTEXT', - 'blob_test' => 'BLOB', - 'text_test' => 'TEXT', + 'char_test' => 'CHAR', + 'varchar_test' => 'VARCHAR', + 'varbinary_test' => 'VARBINARY', + 'tiny_blob_test' => 'TINYBLOB', + 'tiny_text_test' => 'TINYTEXT', + 'blob_test' => 'BLOB', + 'text_test' => 'TEXT', 'medium_blob_test' => 'MEDIUMBLOB', 'medium_text_test' => 'MEDIUMTEXT', - 'long_blob_test' => 'LONGBLOB', - 'long_text_test' => 'LONGTEXT', + 'long_blob_test' => 'LONGBLOB', + 'long_text_test' => 'LONGTEXT', }.each do |field, type| it "should return a String for #{type}" do expect(test_result[field]).to be_an_instance_of(String) diff --git a/spec/mysql2/statement_spec.rb b/spec/mysql2/statement_spec.rb index 3c00d0ffc..57e590804 100644 --- a/spec/mysql2/statement_spec.rb +++ b/spec/mysql2/statement_spec.rb @@ -1,4 +1,4 @@ -require './spec/spec_helper.rb' +require './spec/spec_helper' RSpec.describe Mysql2::Statement do before(:example) do @@ -277,7 +277,7 @@ def stmt_count end context "#each" do - # note: The current impl. of prepared statement requires results to be cached on #execute except for streaming queries + # NOTE: The current impl. of prepared statement requires results to be cached on #execute except for streaming queries # The drawback of this is that args of Result#each is ignored... it "should yield rows as hash's" do @@ -320,7 +320,7 @@ def stmt_count result = @client.prepare("SELECT 1 UNION SELECT 2").execute(stream: true, cache_rows: false) expect do result.each {} - result.each {} + result.each {} # rubocop:disable Style/CombinableLoops end.to raise_exception(Mysql2::Error) end end @@ -573,17 +573,17 @@ def stmt_count end { - 'char_test' => 'CHAR', - 'varchar_test' => 'VARCHAR', - 'varbinary_test' => 'VARBINARY', - 'tiny_blob_test' => 'TINYBLOB', - 'tiny_text_test' => 'TINYTEXT', - 'blob_test' => 'BLOB', - 'text_test' => 'TEXT', + 'char_test' => 'CHAR', + 'varchar_test' => 'VARCHAR', + 'varbinary_test' => 'VARBINARY', + 'tiny_blob_test' => 'TINYBLOB', + 'tiny_text_test' => 'TINYTEXT', + 'blob_test' => 'BLOB', + 'text_test' => 'TEXT', 'medium_blob_test' => 'MEDIUMBLOB', 'medium_text_test' => 'MEDIUMTEXT', - 'long_blob_test' => 'LONGBLOB', - 'long_text_test' => 'LONGTEXT', + 'long_blob_test' => 'LONGBLOB', + 'long_text_test' => 'LONGTEXT', }.each do |field, type| it "should return a String for #{type}" do expect(test_result[field]).to be_an_instance_of(String) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2e86e112c..594e7d339 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -32,6 +32,7 @@ def new_client(option_overrides = {}) @clients ||= [] @clients << client return client unless block_given? + begin yield client ensure @@ -42,7 +43,7 @@ def new_client(option_overrides = {}) def num_classes # rubocop:disable Lint/UnifiedInteger - 0.class == Integer ? [Integer] : [Fixnum, Bignum] + 0.instance_of?(Integer) ? [Integer] : [Fixnum, Bignum] # rubocop:enable Lint/UnifiedInteger end diff --git a/support/mysql_enc_to_ruby.rb b/support/mysql_enc_to_ruby.rb index 33c878885..4db703409 100644 --- a/support/mysql_enc_to_ruby.rb +++ b/support/mysql_enc_to_ruby.rb @@ -55,7 +55,7 @@ collations.each do |collation| mysql_col_idx = collation[2].to_i rb_enc = mysql_to_rb.fetch(collation[1]) do |mysql_enc| - $stderr.puts "WARNING: Missing mapping for collation \"#{collation[0]}\" with encoding \"#{mysql_enc}\" and id #{mysql_col_idx}, assuming NULL" + warn "WARNING: Missing mapping for collation \"#{collation[0]}\" with encoding \"#{mysql_enc}\" and id #{mysql_col_idx}, assuming NULL" "NULL" end encodings[mysql_col_idx - 1] = [mysql_col_idx, rb_enc] From 75665fade70b6202ea4608612cb2547e60a8be45 Mon Sep 17 00:00:00 2001 From: mishina Date: Mon, 30 May 2022 22:52:34 +0900 Subject: [PATCH 4/7] Regenerate .rubocop_todo.yml to let rubocop pass --- .rubocop_todo.yml | 143 +++++++++++++++++++++++++++++++++--------- ext/mysql2/extconf.rb | 2 +- 2 files changed, 113 insertions(+), 32 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f52e30cb8..623647eff 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,28 +1,41 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-11-25 19:54:28 -0500 using RuboCop version 0.50.0. +# on 2022-05-30 13:48:55 UTC using RuboCop version 1.30.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent +# This cop supports safe autocorrection (--autocorrect). Layout/HeredocIndentation: Exclude: - 'support/ruby_enc_to_mysql.rb' - 'tasks/compile.rake' # Offense count: 2 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/mysql2/client_spec.rb' + - 'tasks/rspec.rake' + +# Offense count: 1 +Lint/MissingSuper: + Exclude: + - 'lib/mysql2/em.rb' + +# Offense count: 2 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: - Max: 91 + Max: 94 -# Offense count: 31 -# Configuration parameters: CountComments, ExcludedMethods. +# Offense count: 34 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine Metrics/BlockLength: - Max: 860 + Max: 592 # Offense count: 1 # Configuration parameters: CountBlocks. @@ -30,66 +43,134 @@ Metrics/BlockNesting: Max: 5 # Offense count: 1 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: Max: 135 # Offense count: 3 +# Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: - Max: 32 - -# Offense count: 313 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 232 + Max: 34 # Offense count: 6 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 57 # Offense count: 2 +# Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: - Max: 29 + Max: 32 -# Offense count: 3 -# Configuration parameters: Blacklist. -# Blacklist: END, (?-mix:EO[A-Z]{1}) +# Offense count: 2 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - 'tasks/compile.rake' -# Offense count: 10 +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/CaseLikeIf: + Exclude: + - 'ext/mysql2/extconf.rb' + +# Offense count: 8 +# Configuration parameters: AllowedConstants. Style/Documentation: Exclude: - 'spec/**/*' - 'test/**/*' - 'benchmark/active_record.rb' - 'benchmark/allocations.rb' - - 'benchmark/query_with_mysql_casting.rb' - 'lib/mysql2.rb' - 'lib/mysql2/client.rb' - 'lib/mysql2/em.rb' - 'lib/mysql2/error.rb' - - 'lib/mysql2/result.rb' - 'lib/mysql2/statement.rb' -# Offense count: 14 +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Style/ExpandPathArguments: + Exclude: + - 'ext/mysql2/extconf.rb' + - 'mysql2.gemspec' + - 'spec/mysql2/client_spec.rb' + - 'support/mysql_enc_to_ruby.rb' + - 'tasks/compile.rake' + +# Offense count: 15 # Configuration parameters: AllowedVariables. Style/GlobalVars: Exclude: - 'ext/mysql2/extconf.rb' -# Offense count: 17 -# Cop supports --auto-correct. -# Configuration parameters: Strict. +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Exclude: + - 'lib/mysql2.rb' + - 'lib/mysql2/client.rb' + - 'spec/mysql2/client_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMethodComparison. +Style/MultipleComparison: + Exclude: + - 'lib/mysql2/client.rb' + +# Offense count: 18 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Strict, AllowedNumbers. Style/NumericLiterals: MinDigits: 20 -# Offense count: 726 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'benchmark/setup_db.rb' + - 'ext/mysql2/extconf.rb' + - 'lib/mysql2/em.rb' + +# Offense count: 14 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'benchmark/active_record.rb' + - 'benchmark/active_record_threaded.rb' + - 'benchmark/allocations.rb' + - 'benchmark/escape.rb' + - 'benchmark/query_with_mysql_casting.rb' + - 'benchmark/query_without_mysql_casting.rb' + - 'benchmark/sequel.rb' + - 'benchmark/setup_db.rb' + - 'ext/mysql2/extconf.rb' + - 'lib/mysql2/client.rb' + - 'tasks/compile.rake' + +# Offense count: 782 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 4 + +# Offense count: 32 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 232 diff --git a/ext/mysql2/extconf.rb b/ext/mysql2/extconf.rb index 75fc8c0ab..ea9f448e6 100644 --- a/ext/mysql2/extconf.rb +++ b/ext/mysql2/extconf.rb @@ -181,7 +181,7 @@ def add_ssl_defines(header) end end -unless disabled_sanitizers.empty? +unless disabled_sanitizers.empty? # rubocop:disable Style/IfUnlessModifier abort "-----\nCould not enable requested sanitizers: #{disabled_sanitizers.join(',')}\n-----" end From 0d9622db9903f0481c4ebde6562335e4f1489246 Mon Sep 17 00:00:00 2001 From: mishina Date: Mon, 30 May 2022 22:37:22 +0900 Subject: [PATCH 5/7] Opt out NewCops and RuboCop extensions --- .rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 74224c6b4..856e99da9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,6 +2,8 @@ inherit_from: .rubocop_todo.yml AllCops: TargetRubyVersion: 2.0 + SuggestExtensions: false + NewCops: disable DisplayCopNames: true Exclude: From ad9d23b3a82b1c70038062aee1e34150e4efeb22 Mon Sep 17 00:00:00 2001 From: mishina Date: Sat, 4 Jun 2022 08:06:18 +0900 Subject: [PATCH 6/7] Remove the extra `psych` for older versions of RuboCop --- Gemfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index 96429bf8a..6147ee62d 100644 --- a/Gemfile +++ b/Gemfile @@ -16,8 +16,6 @@ group :test do gem 'eventmachine' unless RUBY_PLATFORM =~ /mswin|mingw/ gem 'rspec', '~> 3.2' - # Downgrade psych because old RuboCop can't use new Psych - gem 'psych', '< 4.0.0' # https://github.com/bbatsov/rubocop/pull/4789 gem 'rubocop', '~> 1.30' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') end From aee1fcb65df4505277de7e6c894b115509982a0a Mon Sep 17 00:00:00 2001 From: mishina Date: Mon, 6 Jun 2022 22:58:32 +0900 Subject: [PATCH 7/7] Upgrade RuboCop to >= 1.30.1 RuboCop v1.30.1 fixed a false positive for Style/SafeNavigation --- .rubocop_todo.yml | 10 ---------- Gemfile | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 623647eff..bc717490d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -126,16 +126,6 @@ Style/MultipleComparison: Style/NumericLiterals: MinDigits: 20 -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. -# AllowedMethods: present?, blank?, presence, try, try! -Style/SafeNavigation: - Exclude: - - 'benchmark/setup_db.rb' - - 'ext/mysql2/extconf.rb' - - 'lib/mysql2/em.rb' - # Offense count: 14 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. diff --git a/Gemfile b/Gemfile index 6147ee62d..7b4e1b8a7 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ group :test do gem 'rspec', '~> 3.2' # https://github.com/bbatsov/rubocop/pull/4789 - gem 'rubocop', '~> 1.30' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') + gem 'rubocop', '~> 1.30', '>= 1.30.1' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') end group :benchmarks, optional: true do