Skip to content

Commit

Permalink
Bump rubocop to 0.71 / Enable Style/FrozenStringLiteralComment rule (
Browse files Browse the repository at this point in the history
…zdennis#767)

* Bump rubocop from 0.40 to 0.71

Since rubocop v0.71 support Ruby v2.7

* Rename cop: `Style/MethodName→Naming/MethodName` / `Style/FileName→Naming/FileName`

* Fix `Layout/TrailingBlankLines`

* Fix `Style/Encoding`

* Fix `Style/FrozenStringLiteralComment`, `Layout/EmptyLineAfterMagicComment`

* Update rubocop setting
  • Loading branch information
toshimaru authored Apr 8, 2022
1 parent ea304fd commit 74ea5b1
Show file tree
Hide file tree
Showing 116 changed files with 316 additions and 24 deletions.
82 changes: 74 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
inherit_from: .rubocop_todo.yml

Lint/EndAlignment:
AlignWith: variable

Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Enabled: false

Metrics/ClassLength:
Enabled: false

Expand All @@ -24,19 +24,34 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Enabled: false

Style/AlignParameters:
EnforcedStyle: with_fixed_indentation
Style/CommentedKeyword:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/Documentation:
Enabled: false

Style/ElseAlignment:
Style/EvalWithLocation:
Enabled: false

Style/ExpandPathArguments:
Enabled: false

Style/GuardClause:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

Style/NumericPredicate:
Enabled: false

Style/PercentLiteralDelimiters:
Enabled: false

Style/SpaceInsideParens:
Style/RedundantBegin:
Enabled: false

Style/SpecialGlobalVars:
Expand All @@ -45,5 +60,56 @@ Style/SpecialGlobalVars:
Style/StringLiterals:
Enabled: false

Style/TrailingCommaInLiteral:
Style/SymbolArray:
Enabled: false

Style/TrailingCommaInArrayLiteral:
Enabled: false

Layout/AlignArguments:
Enabled: false

Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation

Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Layout/ElseAlignment:
Enabled: false

Layout/EmptyLineAfterGuardClause:
Enabled: false

Layout/IndentHeredoc:
Enabled: false

Layout/SpaceInsideParens:
Enabled: false

Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: false

Lint/ErbNewArguments:
Enabled: false

Lint/MissingCopEnableDirective:
Enabled: false

Lint/PercentStringArray:
Enabled: false

Naming/HeredocDelimiterNaming:
Enabled: false

Naming/UncommunicativeMethodParamName:
Enabled: false

Security/YAMLLoad:
Enabled: false

Gemspec/RequiredRubyVersion:
Enabled: false

Bundler/OrderedGems:
Enabled: false
4 changes: 3 additions & 1 deletion Brewfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

brew "mysql"
brew "postgresql"
brew "sqlite"
brew "sqlite"
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
Expand All @@ -13,7 +15,7 @@ pg_version = '0.9'
pg_version = '1.1' if version >= 6.1

group :development, :test do
gem 'rubocop', '~> 0.40.0'
gem 'rubocop', '~> 0.71.0'
gem 'rake'
end

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler"
Bundler.setup

Expand Down
3 changes: 2 additions & 1 deletion activerecord-import.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true

require File.expand_path('../lib/activerecord-import/version', __FILE__)

Gem::Specification.new do |gem|
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/benchmark.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'pathname'
require "fileutils"
require "active_record"
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/lib/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class BenchmarkBase
attr_reader :results

Expand Down
4 changes: 3 additions & 1 deletion benchmarks/lib/cli_parser.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'optparse'
require 'ostruct'

Expand All @@ -8,7 +10,7 @@
# * t - the table types to test. ie: myisam, innodb, memory, temporary, etc.
#
module BenchmarkOptionParser
BANNER = "Usage: ruby #{$0} [options]\nSee ruby #{$0} -h for more options.".freeze
BANNER = "Usage: ruby #{$0} [options]\nSee ruby #{$0} -h for more options."

def self.print_banner
puts BANNER
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/lib/float.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Taken from http://www.programmingishard.com/posts/show/128
# Posted by rbates
class Float
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/lib/mysql2_benchmark.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Mysql2Benchmark < BenchmarkBase
def benchmark_all( array_of_cols_and_vals )
methods = self.methods.find_all { |m| m =~ /benchmark_/ }
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/lib/output_to_csv.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'csv'

module OutputToCSV
Expand Down
6 changes: 4 additions & 2 deletions benchmarks/lib/output_to_html.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# frozen_string_literal: true

require 'erb'

module OutputToHTML
TEMPLATE_HEADER = <<"EOT".freeze
TEMPLATE_HEADER = <<"EOT"
<div>
All times are rounded to the nearest thousandth for display purposes. Speedups next to each time are computed
before any rounding occurs. Also, all speedup calculations are computed by comparing a given time against
the very first column (which is always the default ActiveRecord::Base.create method.
</div>
EOT

TEMPLATE = <<"EOT".freeze
TEMPLATE = <<"EOT"
<style>
td#benchmarkTitle {
border: 1px solid black;
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/models/test_innodb.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class TestInnoDb < ActiveRecord::Base
self.table_name = 'test_innodb'
end
2 changes: 2 additions & 0 deletions benchmarks/models/test_memory.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class TestMemory < ActiveRecord::Base
self.table_name = 'test_memory'
end
2 changes: 2 additions & 0 deletions benchmarks/models/test_myisam.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class TestMyISAM < ActiveRecord::Base
self.table_name = 'test_myisam'
end
2 changes: 2 additions & 0 deletions benchmarks/schema/mysql2_schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ActiveRecord::Schema.define do
create_table :test_myisam, options: 'ENGINE=MyISAM', force: true do |t|
t.column :my_name, :string, null: false
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/4.2.gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

gem 'activerecord', '~> 4.2.0'
gem 'composite_primary_keys', '~> 8.0'
2 changes: 2 additions & 0 deletions gemfiles/5.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

gem 'activerecord', '~> 5.0.0'
gem 'composite_primary_keys', '~> 9.0'
2 changes: 2 additions & 0 deletions gemfiles/5.1.gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

gem 'activerecord', '~> 5.1.0'
gem 'composite_primary_keys', '~> 10.0'
2 changes: 2 additions & 0 deletions gemfiles/5.2.gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

gem 'activerecord', '~> 5.2.0'
gem 'composite_primary_keys', '~> 11.0'
2 changes: 2 additions & 0 deletions gemfiles/6.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

gem 'activerecord', '~> 6.0.0'
gem 'composite_primary_keys', '~> 12.0'
2 changes: 2 additions & 0 deletions gemfiles/6.1.gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

gem 'activerecord', '~> 6.1.0'
gem 'composite_primary_keys', '~> 13.0'
2 changes: 2 additions & 0 deletions gemfiles/7.0.gemfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

gem 'activerecord', '~> 7.0.0'
4 changes: 3 additions & 1 deletion lib/activerecord-import.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# rubocop:disable Style/FileName
# rubocop:disable Naming/FileName
# frozen_string_literal: true

require "active_support/lazy_load_hooks"

ActiveSupport.on_load(:active_record) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "activerecord-import/adapters/abstract_adapter"

module ActiveRecord # :nodoc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_record/connection_adapters/mysql2_adapter"
require "activerecord-import/adapters/mysql2_adapter"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_record/connection_adapters/postgresql_adapter"
require "activerecord-import/adapters/postgresql_adapter"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_record/connection_adapters/sqlite3_adapter"
require "activerecord-import/adapters/sqlite3_adapter"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_record/connection_adapters/mysql2_adapter"
require "activerecord-import/adapters/mysql2_adapter"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_record/connection_adapters/postgresql_adapter"
require "activerecord-import/adapters/postgresql_adapter"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "seamless_database_pool"
require "active_record/connection_adapters/seamless_database_pool_adapter"
require "activerecord-import/adapters/mysql_adapter"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "active_record/connection_adapters/sqlite3_adapter"
require "activerecord-import/adapters/sqlite3_adapter"

Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-import/adapters/abstract_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord::Import::AbstractAdapter
module InstanceMethods
def next_value_for_sequence(sequence_name)
Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-import/adapters/em_mysql2_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "activerecord-import/adapters/mysql_adapter"

module ActiveRecord::Import::EMMysql2Adapter
Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-import/adapters/mysql2_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "activerecord-import/adapters/mysql_adapter"

module ActiveRecord::Import::Mysql2Adapter
Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-import/adapters/mysql_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord::Import::MysqlAdapter
include ActiveRecord::Import::ImportSupport
include ActiveRecord::Import::OnDuplicateKeyUpdateSupport
Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-import/adapters/postgresql_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord::Import::PostgreSQLAdapter
include ActiveRecord::Import::ImportSupport
include ActiveRecord::Import::OnDuplicateKeyUpdateSupport
Expand Down
6 changes: 4 additions & 2 deletions lib/activerecord-import/adapters/sqlite3_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

module ActiveRecord::Import::SQLite3Adapter
include ActiveRecord::Import::ImportSupport
include ActiveRecord::Import::OnDuplicateKeyUpdateSupport

MIN_VERSION_FOR_IMPORT = "3.7.11".freeze
MIN_VERSION_FOR_UPSERT = "3.24.0".freeze
MIN_VERSION_FOR_IMPORT = "3.7.11"
MIN_VERSION_FOR_UPSERT = "3.24.0"
SQLITE_LIMIT_COMPOUND_SELECT = 500

# Override our conformance to ActiveRecord::Import::ImportSupport interface
Expand Down
4 changes: 3 additions & 1 deletion lib/activerecord-import/base.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require "pathname"
require "active_record"
require "active_record/version"

module ActiveRecord::Import
ADAPTER_PATH = "activerecord-import/active_record/adapters".freeze
ADAPTER_PATH = "activerecord-import/active_record/adapters"

def self.base_adapter(adapter)
case adapter
Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-import/import.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "ostruct"

module ActiveRecord::Import::ConnectionAdapters; end
Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-import/mysql2.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

warn <<-MSG
[DEPRECATION] loading activerecord-import via 'require "activerecord-import/<adapter-name>"'
is deprecated. Update to autorequire using 'require "activerecord-import"'. See
Expand Down
Loading

0 comments on commit 74ea5b1

Please sign in to comment.