Skip to content

Commit

Permalink
fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
serggl committed May 20, 2024
1 parent 5292855 commit 23ac596
Show file tree
Hide file tree
Showing 6,312 changed files with 1,235,755 additions and 15 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 1 addition & 2 deletions .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler: 1
ruby-version: 3.2
bundler-cache: true

- name: Run rubocop
Expand Down
9 changes: 8 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ AllCops:
- 'vendor/**/*'
- 'gemfiles/**/*'

Layout/TrailingBlankLines:
Gemspec/RequiredRubyVersion:
Enabled: false

Layout/TrailingEmptyLines:
Enabled: false

Metrics/BlockLength:
Expand All @@ -12,6 +15,10 @@ Metrics/BlockLength:
Metrics/LineLength:
Max: 120

Naming/FileName:
Exclude:
- lib/rails-data-migrations.rb

Style/Documentation:
Enabled: false

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

ruby_version = Gem::Version.new(RUBY_VERSION)

if ruby_version < Gem::Version.new('2.7.0')
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in activerecord-data-migrations.gemspec
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/gem_tasks'
require 'rspec/core/rake_task'

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

require 'rails/version'

module ActiveRecord
Expand Down
4 changes: 3 additions & 1 deletion lib/generators/data_migration_generator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

require 'rails/generators'
require 'rails-data-migrations'

class DataMigrationGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
source_root File.expand_path('templates', __dir__)

def create_migration_file
migration_file_name =
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/templates/data_migration_generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ClassName < ActiveRecord::DataMigration
def up
# put your code here
Expand Down
4 changes: 2 additions & 2 deletions lib/rails-data-migrations.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# rubocop:disable Naming/FileName
# frozen_string_literal: true

require 'rails'
require 'active_record'
require 'active_record/data_migration'
require 'rails_data_migrations/version'
require 'rails_data_migrations/log_entry'
require 'rails_data_migrations/migrator'
require 'rails_data_migrations/railtie'
# rubocop:enable Naming/FileName
4 changes: 3 additions & 1 deletion lib/rails_data_migrations/log_entry.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

module RailsDataMigrations
class LogEntry < ::ActiveRecord::SchemaMigration
class << self
def table_name
ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
"#{ActiveRecord::Base.table_name_prefix}data_migrations#{ActiveRecord::Base.table_name_suffix}"
end

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

module RailsDataMigrations
class Migrator < ::ActiveRecord::Migrator
MIGRATOR_SALT = 2053462855
Expand Down Expand Up @@ -61,7 +63,7 @@ def list_pending_migrations
already_migrated = get_all_versions
list_migrations.reject { |m| already_migrated.include?(m.version) }
else
open(migrations_path).pending_migrations
open(migrations_path).pending_migrations # rubocop:disable Security/Open
end
end

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

require 'rails'

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

module RailsDataMigrations
VERSION = '1.2.0'.freeze
VERSION = '1.2.0'
end
6 changes: 5 additions & 1 deletion lib/tasks/data_migrations.rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# frozen_string_literal: true

require 'rake'

namespace :data do
def apply_single_migration(direction, version)
raise 'VERSION is required' unless version

RailsDataMigrations::Migrator.run_migration(
direction,
RailsDataMigrations::Migrator.migrations_path,
Expand Down Expand Up @@ -42,7 +45,8 @@ namespace :data do
desc 'Skip single data migration using VERSION'
task skip: :init_migration do
version = ENV['VERSION'].to_i
raise 'VERSION is required' unless version > 0
raise 'VERSION is required' unless version.positive?

if RailsDataMigrations::LogEntry.where(version: version).any?
puts "data migration #{version} was already applied."
else
Expand Down
16 changes: 13 additions & 3 deletions rails-data-migrations.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rails_data_migrations/version'

Expand All @@ -23,6 +25,14 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'appraisal', '~> 2.1'
spec.add_development_dependency 'rake', '>= 12.3.3'
spec.add_development_dependency 'rspec', '3.5.0'
spec.add_development_dependency 'rubocop', '0.52.1'
spec.add_development_dependency 'sqlite3', '~> 1.3.6'

spec.add_development_dependency(
'rubocop',
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') ? '~> 1.63' : '0.52.1'
)

spec.add_development_dependency(
'sqlite3',
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') ? '~> 1.3' : '~> 1.3.6'
)
end
4 changes: 3 additions & 1 deletion spec/data_migrations_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe RailsDataMigrations do
Expand Down Expand Up @@ -44,7 +46,7 @@
end

def load_rake_rasks
load File.expand_path('../../lib/tasks/data_migrations.rake', __FILE__)
load File.expand_path('../lib/tasks/data_migrations.rake', __dir__)
Rake::Task.define_task(:environment)
end

Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require 'rails/generators'
require 'rake'

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'rails-data-migrations'

ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
Expand Down
27 changes: 27 additions & 0 deletions vendor/bundle/ruby/2.7.0/bin/appraisal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'appraisal' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('appraisal', 'appraisal', version)
else
gem "appraisal", version
load Gem.bin_path("appraisal", "appraisal", version)
end
27 changes: 27 additions & 0 deletions vendor/bundle/ruby/2.7.0/bin/htmldiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'diff-lcs' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('diff-lcs', 'htmldiff', version)
else
gem "diff-lcs", version
load Gem.bin_path("diff-lcs", "htmldiff", version)
end
27 changes: 27 additions & 0 deletions vendor/bundle/ruby/2.7.0/bin/irb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'irb' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('irb', 'irb', version)
else
gem "irb", version
load Gem.bin_path("irb", "irb", version)
end
27 changes: 27 additions & 0 deletions vendor/bundle/ruby/2.7.0/bin/ldiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'diff-lcs' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('diff-lcs', 'ldiff', version)
else
gem "diff-lcs", version
load Gem.bin_path("diff-lcs", "ldiff", version)
end
27 changes: 27 additions & 0 deletions vendor/bundle/ruby/2.7.0/bin/nokogiri
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'nokogiri' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('nokogiri', 'nokogiri', version)
else
gem "nokogiri", version
load Gem.bin_path("nokogiri", "nokogiri", version)
end
27 changes: 27 additions & 0 deletions vendor/bundle/ruby/2.7.0/bin/racc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'racc' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('racc', 'racc', version)
else
gem "racc", version
load Gem.bin_path("racc", "racc", version)
end
27 changes: 27 additions & 0 deletions vendor/bundle/ruby/2.7.0/bin/rackup
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'rackup' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

str = ARGV.first
if str
str = str.b[/\A_(.*)_\z/, 1]
if str and Gem::Version.correct?(str)
version = str
ARGV.shift
end
end

if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('rackup', 'rackup', version)
else
gem "rackup", version
load Gem.bin_path("rackup", "rackup", version)
end
Loading

0 comments on commit 23ac596

Please sign in to comment.