From 246ff320999149ad4813f2a6c9f6fd7afb3ea8e8 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 16 Jul 2020 11:47:48 +0800 Subject: [PATCH 1/6] using official rubocop version and ran auto-correct --- .rubocop.yml | 6 ---- .rubocop_todo.yml | 29 ------------------- Gemfile | 2 +- Rakefile | 8 +++-- lib/apartment.rb | 8 +++-- .../active_record/internal_metadata.rb | 2 -- lib/apartment/active_record/log_subscriber.rb | 4 ++- .../active_record/schema_migration.rb | 2 -- lib/apartment/adapters/abstract_adapter.rb | 8 +++-- .../adapters/jdbc_postgresql_adapter.rb | 4 ++- lib/apartment/adapters/postgresql_adapter.rb | 12 ++++++-- lib/apartment/console.rb | 10 ++----- lib/apartment/custom_console.rb | 2 -- lib/apartment/tasks/task_helper.rb | 2 -- lib/apartment/tenant.rb | 4 ++- spec/adapters/postgresql_adapter_spec.rb | 6 +++- 16 files changed, 44 insertions(+), 65 deletions(-) delete mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 2c505894..4d999ea2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,3 @@ -inherit_from: .rubocop_todo.yml - -inherit_gem: - perx-rubocop: - - default.yml - AllCops: Exclude: - 'gemfiles/**/*.gemfile' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index dd9305f8..00000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2020-02-16 15:36:55 +0800 using RuboCop version 0.77.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: 5 -Metrics/AbcSize: - Max: 33 - -# Offense count: 11 -# Configuration parameters: CountComments, ExcludedMethods. -# ExcludedMethods: refine -Metrics/BlockLength: - Max: 176 - -# Offense count: 18 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 200 - -# Offense count: 4 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/MethodLength: - Max: 24 diff --git a/Gemfile b/Gemfile index c17fcbee..fa74281e 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,8 @@ source 'https://my.diffend.io/protect/gems' gemspec -gem 'perx-rubocop', '~> 0.0.3' gem 'rails', '>= 3.1.2' +gem 'rubocop' group :local do gem 'guard-rspec', '~> 4.2' diff --git a/Rakefile b/Rakefile index 735d192c..59c5fbc9 100644 --- a/Rakefile +++ b/Rakefile @@ -46,8 +46,12 @@ namespace :db do apartment_db_file = 'spec/config/database.yml' rails_db_file = 'spec/dummy/config/database.yml' - FileUtils.copy(apartment_db_file + '.sample', apartment_db_file, verbose: true) unless File.exist?(apartment_db_file) - FileUtils.copy(rails_db_file + '.sample', rails_db_file, verbose: true) unless File.exist?(rails_db_file) + unless File.exist?(apartment_db_file) + FileUtils.copy(apartment_db_file + '.sample', apartment_db_file, verbose: true) + end + unless File.exist?(rails_db_file) + FileUtils.copy(rails_db_file + '.sample', rails_db_file, verbose: true) + end end end diff --git a/lib/apartment.rb b/lib/apartment.rb index b0371297..c04b0cc7 100644 --- a/lib/apartment.rb +++ b/lib/apartment.rb @@ -9,7 +9,9 @@ # require_relative 'apartment/arel/visitors/postgresql' require_relative 'apartment/active_record/log_subscriber' -require_relative 'apartment/active_record/connection_handling' if ActiveRecord.version.release >= Gem::Version.new('6.0') +if ActiveRecord.version.release >= Gem::Version.new('6.0') + require_relative 'apartment/active_record/connection_handling' +end if ActiveRecord.version.release >= Gem::Version.new('6.1') require_relative 'apartment/active_record/schema_migration' @@ -106,7 +108,9 @@ def pg_excluded_names # Reset all the config for Apartment def reset (ACCESSOR_METHODS + WRITER_METHODS).each do |method| - remove_instance_variable(:"@#{method}") if instance_variable_defined?(:"@#{method}") + if instance_variable_defined?(:"@#{method}") + remove_instance_variable(:"@#{method}") + end end end diff --git a/lib/apartment/active_record/internal_metadata.rb b/lib/apartment/active_record/internal_metadata.rb index 2c494990..4febd0cf 100644 --- a/lib/apartment/active_record/internal_metadata.rb +++ b/lib/apartment/active_record/internal_metadata.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop:disable Rails/ApplicationRecord class InternalMetadata < ActiveRecord::Base # :nodoc: class << self def table_exists? @@ -8,4 +7,3 @@ def table_exists? end end end -# rubocop:enable Rails/ApplicationRecord diff --git a/lib/apartment/active_record/log_subscriber.rb b/lib/apartment/active_record/log_subscriber.rb index ca090264..a0e4bea5 100644 --- a/lib/apartment/active_record/log_subscriber.rb +++ b/lib/apartment/active_record/log_subscriber.rb @@ -7,7 +7,9 @@ def apartment_log database = color("[#{Apartment.connection.current_database}] ", ActiveSupport::LogSubscriber::MAGENTA, true) schema = nil - schema = color("[#{Apartment.connection.schema_search_path.tr('"', '')}] ", ActiveSupport::LogSubscriber::YELLOW, true) unless Apartment.connection.schema_search_path.nil? + unless Apartment.connection.schema_search_path.nil? + schema = color("[#{Apartment.connection.schema_search_path.tr('"', '')}] ", ActiveSupport::LogSubscriber::YELLOW, true) + end "#{database}#{schema}" end diff --git a/lib/apartment/active_record/schema_migration.rb b/lib/apartment/active_record/schema_migration.rb index 7bc07360..cbad3648 100644 --- a/lib/apartment/active_record/schema_migration.rb +++ b/lib/apartment/active_record/schema_migration.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true module ActiveRecord - # rubocop:disable Rails/ApplicationRecord class SchemaMigration < ActiveRecord::Base # :nodoc: class << self def table_exists? @@ -9,5 +8,4 @@ def table_exists? end end end - # rubocop:enable Rails/ApplicationRecord end diff --git a/lib/apartment/adapters/abstract_adapter.rb b/lib/apartment/adapters/abstract_adapter.rb index ce18f396..544e58b6 100644 --- a/lib/apartment/adapters/abstract_adapter.rb +++ b/lib/apartment/adapters/abstract_adapter.rb @@ -123,7 +123,9 @@ def reset # def seed_data # Don't log the output of seeding the db - silence_warnings { load_or_raise(Apartment.seed_data_file) } if Apartment.seed_data_file + if Apartment.seed_data_file + silence_warnings { load_or_raise(Apartment.seed_data_file) } + end end alias seed seed_data @@ -194,7 +196,9 @@ def connect_to_new(tenant) def import_database_schema ActiveRecord::Schema.verbose = false # do not log schema load output. - load_or_raise(Apartment.database_schema_file) if Apartment.database_schema_file + if Apartment.database_schema_file + load_or_raise(Apartment.database_schema_file) + end end # Return a new config that is multi-tenanted diff --git a/lib/apartment/adapters/jdbc_postgresql_adapter.rb b/lib/apartment/adapters/jdbc_postgresql_adapter.rb index 16113b27..f9477fd0 100644 --- a/lib/apartment/adapters/jdbc_postgresql_adapter.rb +++ b/lib/apartment/adapters/jdbc_postgresql_adapter.rb @@ -39,7 +39,9 @@ def connect_to_new(tenant = nil) return reset if tenant.nil? tenant = tenant.to_s - raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant) + unless tenant_exists?(tenant) + raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" + end @current = tenant Apartment.connection.schema_search_path = full_search_path diff --git a/lib/apartment/adapters/postgresql_adapter.rb b/lib/apartment/adapters/postgresql_adapter.rb index a2ca1163..9d3f7a4a 100644 --- a/lib/apartment/adapters/postgresql_adapter.rb +++ b/lib/apartment/adapters/postgresql_adapter.rb @@ -7,7 +7,9 @@ module Tenant def self.postgresql_adapter(config) adapter = Adapters::PostgresqlAdapter adapter = Adapters::PostgresqlSchemaAdapter if Apartment.use_schemas - adapter = Adapters::PostgresqlSchemaFromSqlAdapter if Apartment.use_sql && Apartment.use_schemas + if Apartment.use_sql && Apartment.use_schemas + adapter = Adapters::PostgresqlSchemaFromSqlAdapter + end adapter.new(config) end end @@ -74,7 +76,9 @@ def connect_to_new(tenant = nil) return reset if tenant.nil? tenant = tenant.to_s - raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant) + unless tenant_exists?(tenant) + raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" + end @current = tenant Apartment.connection.schema_search_path = full_search_path @@ -127,7 +131,9 @@ def reset_sequence_names .each do |c| # NOTE: due to this https://github.com/rails-on-services/apartment/issues/81 # unreproduceable error we're checking before trying to remove it - c.remove_instance_variable :@sequence_name if c.instance_variable_defined?(:@sequence_name) + if c.instance_variable_defined?(:@sequence_name) + c.remove_instance_variable :@sequence_name + end end end end diff --git a/lib/apartment/console.rb b/lib/apartment/console.rb index 7fcb1d61..1398fe72 100644 --- a/lib/apartment/console.rb +++ b/lib/apartment/console.rb @@ -5,9 +5,7 @@ # reloads the environment def reload!(print = true) - # rubocop:disable Rails/Output puts 'Reloading...' if print - # rubocop:enable Rails/Output # This triggers the to_prepare callbacks ActionDispatch::Callbacks.new(proc {}).call({}) @@ -18,15 +16,13 @@ def reload!(print = true) def st(schema_name = nil) if schema_name.nil? - # rubocop:disable Rails/Output tenant_list.each { |t| puts t } - # rubocop:enable Rails/Output + elsif tenant_list.include? schema_name Apartment::Tenant.switch!(schema_name) else - # rubocop:disable Rails/Output puts "Tenant #{schema_name} is not part of the tenant list" - # rubocop:enable Rails/Output + end end @@ -37,8 +33,6 @@ def tenant_list end def tenant_info_msg - # rubocop:disable Rails/Output puts "Available Tenants: #{tenant_list}\n" puts "Use `st 'tenant'` to switch tenants & `tenant_list` to see list\n" - # rubocop:enable Rails/Output end diff --git a/lib/apartment/custom_console.rb b/lib/apartment/custom_console.rb index eae9f4bb..bc3d0902 100644 --- a/lib/apartment/custom_console.rb +++ b/lib/apartment/custom_console.rb @@ -7,9 +7,7 @@ module CustomConsole begin require 'pry-rails' rescue LoadError - # rubocop:disable Rails/Output puts '[Failed to load pry-rails] If you want to use Apartment custom prompt you need to add pry-rails to your gemfile' - # rubocop:enable Rails/Output end desc = "Includes the current Rails environment and project folder name.\n" \ diff --git a/lib/apartment/tasks/task_helper.rb b/lib/apartment/tasks/task_helper.rb index aefa8dd4..84257b9a 100644 --- a/lib/apartment/tasks/task_helper.rb +++ b/lib/apartment/tasks/task_helper.rb @@ -19,7 +19,6 @@ def self.tenants def self.warn_if_tenants_empty return unless tenants.empty? && ENV['IGNORE_EMPTY_TENANTS'] != 'true' - # rubocop:disable Rails/Output puts <<-WARNING [WARNING] - The list of tenants to migrate appears to be empty. This could mean a few things: @@ -29,7 +28,6 @@ def self.warn_if_tenants_empty Note that your tenants currently haven't been migrated. You'll need to run `db:migrate` to rectify this. WARNING - # rubocop:enable Rails/Output end end end diff --git a/lib/apartment/tenant.rb b/lib/apartment/tenant.rb index 17560b27..72a222ff 100644 --- a/lib/apartment/tenant.rb +++ b/lib/apartment/tenant.rb @@ -51,7 +51,9 @@ def adapter raise "The adapter `#{adapter_method}` is not yet supported" end - raise AdapterNotFound, "database configuration specifies nonexistent #{config[:adapter]} adapter" unless respond_to?(adapter_method) + unless respond_to?(adapter_method) + raise AdapterNotFound, "database configuration specifies nonexistent #{config[:adapter]} adapter" + end send(adapter_method, config) end diff --git a/spec/adapters/postgresql_adapter_spec.rb b/spec/adapters/postgresql_adapter_spec.rb index 71366c59..a32e9ccf 100644 --- a/spec/adapters/postgresql_adapter_spec.rb +++ b/spec/adapters/postgresql_adapter_spec.rb @@ -44,7 +44,11 @@ def tenant_names expect { Apartment::Tenant.create('has-dashes') }.to_not raise_error end - after { Apartment::Tenant.drop('has-dashes') if Apartment.connection.schema_exists? 'has-dashes' } + after do + if Apartment.connection.schema_exists? 'has-dashes' + Apartment::Tenant.drop('has-dashes') + end + end end context 'using connections' do From b740deda9baa762014ad828b79847c87f1142943 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 16 Jul 2020 11:50:37 +0800 Subject: [PATCH 2/6] updated rubocop version --- Rakefile | 4 +--- lib/apartment.rb | 4 +--- lib/apartment/adapters/abstract_adapter.rb | 8 ++------ lib/apartment/adapters/jdbc_postgresql_adapter.rb | 4 +--- lib/apartment/adapters/postgresql_adapter.rb | 12 +++--------- spec/adapters/postgresql_adapter_spec.rb | 4 +--- spec/dummy/config.ru | 2 +- spec/dummy_engine/test/dummy/config.ru | 2 +- 8 files changed, 11 insertions(+), 29 deletions(-) diff --git a/Rakefile b/Rakefile index 59c5fbc9..948bd059 100644 --- a/Rakefile +++ b/Rakefile @@ -49,9 +49,7 @@ namespace :db do unless File.exist?(apartment_db_file) FileUtils.copy(apartment_db_file + '.sample', apartment_db_file, verbose: true) end - unless File.exist?(rails_db_file) - FileUtils.copy(rails_db_file + '.sample', rails_db_file, verbose: true) - end + FileUtils.copy(rails_db_file + '.sample', rails_db_file, verbose: true) unless File.exist?(rails_db_file) end end diff --git a/lib/apartment.rb b/lib/apartment.rb index c04b0cc7..e49285c4 100644 --- a/lib/apartment.rb +++ b/lib/apartment.rb @@ -108,9 +108,7 @@ def pg_excluded_names # Reset all the config for Apartment def reset (ACCESSOR_METHODS + WRITER_METHODS).each do |method| - if instance_variable_defined?(:"@#{method}") - remove_instance_variable(:"@#{method}") - end + remove_instance_variable(:"@#{method}") if instance_variable_defined?(:"@#{method}") end end diff --git a/lib/apartment/adapters/abstract_adapter.rb b/lib/apartment/adapters/abstract_adapter.rb index 544e58b6..ce18f396 100644 --- a/lib/apartment/adapters/abstract_adapter.rb +++ b/lib/apartment/adapters/abstract_adapter.rb @@ -123,9 +123,7 @@ def reset # def seed_data # Don't log the output of seeding the db - if Apartment.seed_data_file - silence_warnings { load_or_raise(Apartment.seed_data_file) } - end + silence_warnings { load_or_raise(Apartment.seed_data_file) } if Apartment.seed_data_file end alias seed seed_data @@ -196,9 +194,7 @@ def connect_to_new(tenant) def import_database_schema ActiveRecord::Schema.verbose = false # do not log schema load output. - if Apartment.database_schema_file - load_or_raise(Apartment.database_schema_file) - end + load_or_raise(Apartment.database_schema_file) if Apartment.database_schema_file end # Return a new config that is multi-tenanted diff --git a/lib/apartment/adapters/jdbc_postgresql_adapter.rb b/lib/apartment/adapters/jdbc_postgresql_adapter.rb index f9477fd0..16113b27 100644 --- a/lib/apartment/adapters/jdbc_postgresql_adapter.rb +++ b/lib/apartment/adapters/jdbc_postgresql_adapter.rb @@ -39,9 +39,7 @@ def connect_to_new(tenant = nil) return reset if tenant.nil? tenant = tenant.to_s - unless tenant_exists?(tenant) - raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" - end + raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant) @current = tenant Apartment.connection.schema_search_path = full_search_path diff --git a/lib/apartment/adapters/postgresql_adapter.rb b/lib/apartment/adapters/postgresql_adapter.rb index 9d3f7a4a..a2ca1163 100644 --- a/lib/apartment/adapters/postgresql_adapter.rb +++ b/lib/apartment/adapters/postgresql_adapter.rb @@ -7,9 +7,7 @@ module Tenant def self.postgresql_adapter(config) adapter = Adapters::PostgresqlAdapter adapter = Adapters::PostgresqlSchemaAdapter if Apartment.use_schemas - if Apartment.use_sql && Apartment.use_schemas - adapter = Adapters::PostgresqlSchemaFromSqlAdapter - end + adapter = Adapters::PostgresqlSchemaFromSqlAdapter if Apartment.use_sql && Apartment.use_schemas adapter.new(config) end end @@ -76,9 +74,7 @@ def connect_to_new(tenant = nil) return reset if tenant.nil? tenant = tenant.to_s - unless tenant_exists?(tenant) - raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" - end + raise ActiveRecord::StatementInvalid, "Could not find schema #{tenant}" unless tenant_exists?(tenant) @current = tenant Apartment.connection.schema_search_path = full_search_path @@ -131,9 +127,7 @@ def reset_sequence_names .each do |c| # NOTE: due to this https://github.com/rails-on-services/apartment/issues/81 # unreproduceable error we're checking before trying to remove it - if c.instance_variable_defined?(:@sequence_name) - c.remove_instance_variable :@sequence_name - end + c.remove_instance_variable :@sequence_name if c.instance_variable_defined?(:@sequence_name) end end end diff --git a/spec/adapters/postgresql_adapter_spec.rb b/spec/adapters/postgresql_adapter_spec.rb index a32e9ccf..d7689d26 100644 --- a/spec/adapters/postgresql_adapter_spec.rb +++ b/spec/adapters/postgresql_adapter_spec.rb @@ -45,9 +45,7 @@ def tenant_names end after do - if Apartment.connection.schema_exists? 'has-dashes' - Apartment::Tenant.drop('has-dashes') - end + Apartment::Tenant.drop('has-dashes') if Apartment.connection.schema_exists? 'has-dashes' end end diff --git a/spec/dummy/config.ru b/spec/dummy/config.ru index 989f7c64..4f079dd4 100644 --- a/spec/dummy/config.ru +++ b/spec/dummy/config.ru @@ -2,5 +2,5 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('config/environment', __dir__) run Dummy::Application diff --git a/spec/dummy_engine/test/dummy/config.ru b/spec/dummy_engine/test/dummy/config.ru index 61c04e13..667e328d 100644 --- a/spec/dummy_engine/test/dummy/config.ru +++ b/spec/dummy_engine/test/dummy/config.ru @@ -2,5 +2,5 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('config/environment', __dir__) run Rails.application From 54344949d1c22c1f9df881f4d10d99b90d769cb6 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 16 Jul 2020 11:54:33 +0800 Subject: [PATCH 3/6] ran autocorrect --- .rubocop.yml | 73 +++++++++++++++++++ lib/apartment/active_record/log_subscriber.rb | 3 +- .../adapters/abstract_jdbc_adapter.rb | 2 +- .../adapters/jdbc_postgresql_adapter.rb | 2 +- spec/examples/schema_adapter_examples.rb | 3 - 5 files changed, 76 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4d999ea2..8416df2e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,3 +14,76 @@ Style/NumericLiterals: Layout/EmptyLineAfterMagicComment: Exclude: - spec/schemas/**/*.rb + +Metrics/BlockLength: + Exclude: + - spec/**/*.rb + +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: true + +Layout/SpaceAroundMethodCallOperator: + Enabled: true + +Lint/DeprecatedOpenSSLConstant: + Enabled: true + +Lint/DuplicateElsifCondition: + Enabled: true + +Lint/MixedRegexpCaptureTypes: + Enabled: true + +Lint/RaiseException: + Enabled: true + +Lint/StructNewOverride: + Enabled: true + +Style/AccessorGrouping: + Enabled: true + +Style/ArrayCoercion: + Enabled: true + +Style/BisectedAttrAccessor: + Enabled: true + +Style/CaseLikeIf: + Enabled: true + +Style/ExponentialNotation: + Enabled: true + +Style/HashAsLastArrayItem: + Enabled: true + +Style/HashEachMethods: + Enabled: true + +Style/HashLikeCase: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: true + +Style/RedundantAssignment: + Enabled: true + +Style/RedundantFetchBlock: + Enabled: true + +Style/RedundantFileExtensionInRequire: + Enabled: true + +Style/RedundantRegexpCharacterClass: + Enabled: true + +Style/RedundantRegexpEscape: + Enabled: true + +Style/SlicingWithRange: + Enabled: true diff --git a/lib/apartment/active_record/log_subscriber.rb b/lib/apartment/active_record/log_subscriber.rb index a0e4bea5..5860928b 100644 --- a/lib/apartment/active_record/log_subscriber.rb +++ b/lib/apartment/active_record/log_subscriber.rb @@ -17,8 +17,7 @@ def payload_binds(binds, type_casted_binds) return unless (binds || []).empty? casted_params = type_casted_binds(type_casted_binds) - binds = ' ' + binds.zip(casted_params).map { |attr, value| render_bind(attr, value) }.inspect - binds + ' ' + binds.zip(casted_params).map { |attr, value| render_bind(attr, value) }.inspect end def sql(event) diff --git a/lib/apartment/adapters/abstract_jdbc_adapter.rb b/lib/apartment/adapters/abstract_jdbc_adapter.rb index d37aa79d..6881071e 100644 --- a/lib/apartment/adapters/abstract_jdbc_adapter.rb +++ b/lib/apartment/adapters/abstract_jdbc_adapter.rb @@ -8,7 +8,7 @@ class AbstractJDBCAdapter < AbstractAdapter private def multi_tenantify_with_tenant_db_name(config, tenant) - config[:url] = "#{config[:url].gsub(%r{(\S+)\/.+$}, '\1')}/#{environmentify(tenant)}" + config[:url] = "#{config[:url].gsub(%r{(\S+)/.+$}, '\1')}/#{environmentify(tenant)}" end def rescue_from diff --git a/lib/apartment/adapters/jdbc_postgresql_adapter.rb b/lib/apartment/adapters/jdbc_postgresql_adapter.rb index 16113b27..7f6aed67 100644 --- a/lib/apartment/adapters/jdbc_postgresql_adapter.rb +++ b/lib/apartment/adapters/jdbc_postgresql_adapter.rb @@ -19,7 +19,7 @@ class JDBCPostgresqlAdapter < PostgresqlAdapter private def multi_tenantify_with_tenant_db_name(config, tenant) - config[:url] = "#{config[:url].gsub(%r{(\S+)\/.+$}, '\1')}/#{environmentify(tenant)}" + config[:url] = "#{config[:url].gsub(%r{(\S+)/.+$}, '\1')}/#{environmentify(tenant)}" end def create_tenant_command(conn, tenant) diff --git a/spec/examples/schema_adapter_examples.rb b/spec/examples/schema_adapter_examples.rb index e172d613..447322e3 100644 --- a/spec/examples/schema_adapter_examples.rb +++ b/spec/examples/schema_adapter_examples.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true require 'spec_helper' - -# rubocop:disable Metrics/BlockLength shared_examples_for 'a schema based apartment adapter' do include Apartment::Spec::AdapterRequirements @@ -254,4 +252,3 @@ end end end -# rubocop:enable Metrics/BlockLength From e67b1e0ab2f2a5e193a78841b5d922a024b5bb2f Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 16 Jul 2020 12:16:13 +0800 Subject: [PATCH 4/6] addressed some of the rubocop offenses and added todo --- .rubocop.yml | 2 + .rubocop_todo.yml | 73 +++++++++++++++++++ Guardfile | 15 ---- Rakefile | 2 + lib/apartment.rb | 4 +- .../active_record/connection_handling.rb | 3 + lib/apartment/active_record/log_subscriber.rb | 4 +- lib/apartment/adapters/abstract_adapter.rb | 6 +- .../adapters/abstract_jdbc_adapter.rb | 1 + .../adapters/jdbc_postgresql_adapter.rb | 1 + lib/apartment/adapters/mysql2_adapter.rb | 3 + 11 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 8416df2e..b0a4cc6c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +inherit_from: .rubocop_todo.yml + AllCops: Exclude: - 'gemfiles/**/*.gemfile' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..85e144ed --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,73 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2020-07-16 04:15:41 UTC using RuboCop version 0.88.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: 1 +Lint/MixedRegexpCaptureTypes: + Exclude: + - 'lib/apartment/elevators/domain.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/NonDeterministicRequireOrder: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 7 +# Configuration parameters: IgnoredMethods. +Metrics/AbcSize: + Max: 33 + +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 102 + +# Offense count: 1 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 151 + +# Offense count: 6 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. +Metrics/MethodLength: + Max: 24 + +# Offense count: 17 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/apartment/adapters/jdbc_mysql_adapter.rb' + - 'lib/apartment/adapters/postgis_adapter.rb' + - 'lib/apartment/adapters/postgresql_adapter.rb' + - 'lib/apartment/adapters/sqlite3_adapter.rb' + - 'lib/apartment/custom_console.rb' + - 'lib/apartment/deprecation.rb' + - 'lib/apartment/migrator.rb' + - 'lib/apartment/model.rb' + - 'lib/apartment/railtie.rb' + - 'lib/apartment/reloader.rb' + - 'lib/apartment/tasks/enhancements.rb' + - 'lib/apartment/tasks/task_helper.rb' + - 'lib/generators/apartment/install/install_generator.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'Rakefile' + - 'lib/apartment.rb' + - 'lib/apartment/tenant.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 171 diff --git a/Guardfile b/Guardfile index ffec03ce..335bab54 100644 --- a/Guardfile +++ b/Guardfile @@ -8,19 +8,4 @@ guard :rspec do watch(%r{^lib/apartment/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" } watch(%r{^lib/apartment/(.+)\.rb$}) { |m| "spec/integration/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { 'spec' } - - # # Rails example - # watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - # watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - # watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } - # watch(%r{^spec/support/(.+)\.rb$}) { "spec" } - # watch('config/routes.rb') { "spec/routing" } - # watch('app/controllers/application_controller.rb') { "spec/controllers" } - - # # Capybara features specs - # watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } - - # # Turnip features and steps - # watch(%r{^spec/acceptance/(.+)\.feature$}) - # watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } end diff --git a/Rakefile b/Rakefile index 948bd059..62e89b26 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ # frozen_string_literal: true +# rubocop:disable Metrics/BlockLength begin require 'bundler' rescue StandardError @@ -117,6 +118,7 @@ namespace :mysql do `mysqladmin #{params.join(' ')} drop #{my_config['database']} --force` end end +# rubocop:enable Metrics/BlockLength # TODO: clean this up def config diff --git a/lib/apartment.rb b/lib/apartment.rb index e49285c4..6bca1cc8 100644 --- a/lib/apartment.rb +++ b/lib/apartment.rb @@ -6,9 +6,8 @@ require 'active_record' require 'apartment/tenant' -# require_relative 'apartment/arel/visitors/postgresql' - require_relative 'apartment/active_record/log_subscriber' + if ActiveRecord.version.release >= Gem::Version.new('6.0') require_relative 'apartment/active_record/connection_handling' end @@ -18,6 +17,7 @@ require_relative 'apartment/active_record/internal_metadata' end +# Apartment main definitions module Apartment class << self extend Forwardable diff --git a/lib/apartment/active_record/connection_handling.rb b/lib/apartment/active_record/connection_handling.rb index c9c1056f..f306258e 100644 --- a/lib/apartment/active_record/connection_handling.rb +++ b/lib/apartment/active_record/connection_handling.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true module ActiveRecord + # This is monkeypatching activerecord to ensure that whenever a new connection is established it + # switches to the same tenant as before the connection switching. This problem is more evident when + # using read replica in Rails 6 module ConnectionHandling def connected_to_with_tenant(database: nil, role: nil, prevent_writes: false, &blk) current_tenant = Apartment::Tenant.current diff --git a/lib/apartment/active_record/log_subscriber.rb b/lib/apartment/active_record/log_subscriber.rb index 5860928b..da5430d1 100644 --- a/lib/apartment/active_record/log_subscriber.rb +++ b/lib/apartment/active_record/log_subscriber.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module ActiveRecord + # Supports the logging configuration to prepend the database and schema in the ActiveRecord log class LogSubscriber def apartment_log return unless Apartment.active_record_log @@ -8,7 +9,8 @@ def apartment_log database = color("[#{Apartment.connection.current_database}] ", ActiveSupport::LogSubscriber::MAGENTA, true) schema = nil unless Apartment.connection.schema_search_path.nil? - schema = color("[#{Apartment.connection.schema_search_path.tr('"', '')}] ", ActiveSupport::LogSubscriber::YELLOW, true) + schema = color("[#{Apartment.connection.schema_search_path.tr('"', '')}] ", + ActiveSupport::LogSubscriber::YELLOW, true) end "#{database}#{schema}" end diff --git a/lib/apartment/adapters/abstract_adapter.rb b/lib/apartment/adapters/abstract_adapter.rb index ce18f396..8ca4f308 100644 --- a/lib/apartment/adapters/abstract_adapter.rb +++ b/lib/apartment/adapters/abstract_adapter.rb @@ -2,7 +2,7 @@ module Apartment module Adapters - # rubocop:disable Metrics/ClassLength + # Abstract adapter from which all the Apartment DB related adapters will inherit the base logic class AbstractAdapter include ActiveSupport::Callbacks define_callbacks :create, :switch @@ -240,7 +240,8 @@ def db_connection_config(tenant) def with_neutral_connection(tenant, &_block) if Apartment.with_multi_server_setup # neutral connection is necessary whenever you need to create/remove a database from a server. - # example: when you use postgresql, you need to connect to the default postgresql database before you create your own. + # example: when you use postgresql, you need to connect to the default postgresql database before you create + # your own. SeparateDbConnectionHandler.establish_connection(multi_tenantify(tenant, false)) yield(SeparateDbConnectionHandler.connection) SeparateDbConnectionHandler.connection.close @@ -269,5 +270,4 @@ class SeparateDbConnectionHandler < ::ActiveRecord::Base end end end - # rubocop:enable Metrics/ClassLength end diff --git a/lib/apartment/adapters/abstract_jdbc_adapter.rb b/lib/apartment/adapters/abstract_jdbc_adapter.rb index 6881071e..4dd0748c 100644 --- a/lib/apartment/adapters/abstract_jdbc_adapter.rb +++ b/lib/apartment/adapters/abstract_jdbc_adapter.rb @@ -4,6 +4,7 @@ module Apartment module Adapters + # JDBC Abstract adapter class AbstractJDBCAdapter < AbstractAdapter private diff --git a/lib/apartment/adapters/jdbc_postgresql_adapter.rb b/lib/apartment/adapters/jdbc_postgresql_adapter.rb index 7f6aed67..70dbadf3 100644 --- a/lib/apartment/adapters/jdbc_postgresql_adapter.rb +++ b/lib/apartment/adapters/jdbc_postgresql_adapter.rb @@ -3,6 +3,7 @@ require 'apartment/adapters/postgresql_adapter' module Apartment + # JDBC helper to decide wether to use JDBC Postgresql Adapter or JDBC Postgresql Adapter with Schemas module Tenant def self.jdbc_postgresql_adapter(config) if Apartment.use_schemas diff --git a/lib/apartment/adapters/mysql2_adapter.rb b/lib/apartment/adapters/mysql2_adapter.rb index 71adbe60..ca9b1a7f 100644 --- a/lib/apartment/adapters/mysql2_adapter.rb +++ b/lib/apartment/adapters/mysql2_adapter.rb @@ -3,6 +3,7 @@ require 'apartment/adapters/abstract_adapter' module Apartment + # Helper module to decide wether to use mysql2 adapter or mysql2 adapter with schemas module Tenant def self.mysql2_adapter(config) if Apartment.use_schemas @@ -14,6 +15,7 @@ def self.mysql2_adapter(config) end module Adapters + # Mysql2 Adapter class Mysql2Adapter < AbstractAdapter def initialize(config) super @@ -28,6 +30,7 @@ def rescue_from end end + # Mysql2 Schemas Adapter class Mysql2SchemaAdapter < AbstractAdapter def initialize(config) super From e2c14e0eb6c152963a257c89cb7f478bf717f84e Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 16 Jul 2020 12:28:56 +0800 Subject: [PATCH 5/6] cleanup line length --- .rubocop_todo.yml | 7 ------- Rakefile | 2 -- lib/apartment/adapters/postgresql_adapter.rb | 21 ++++++++++++------- lib/apartment/custom_console.rb | 2 ++ .../apartment/install/templates/apartment.rb | 3 ++- spec/adapters/jdbc_mysql_adapter_spec.rb | 4 +++- spec/adapters/mysql2_adapter_spec.rb | 4 +++- .../dummy/config/initializers/secret_token.rb | 3 +++ spec/dummy/script/rails | 3 ++- spec/dummy_engine/bin/rails | 3 ++- .../config/initializers/apartment.rb | 3 ++- ...ic_adapter_custom_configuration_example.rb | 8 +++++-- 12 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 85e144ed..c72ac883 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -64,10 +64,3 @@ Style/IfUnlessModifier: - 'Rakefile' - 'lib/apartment.rb' - 'lib/apartment/tenant.rb' - -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 171 diff --git a/Rakefile b/Rakefile index 62e89b26..948bd059 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop:disable Metrics/BlockLength begin require 'bundler' rescue StandardError @@ -118,7 +117,6 @@ namespace :mysql do `mysqladmin #{params.join(' ')} drop #{my_config['database']} --force` end end -# rubocop:enable Metrics/BlockLength # TODO: clean this up def config diff --git a/lib/apartment/adapters/postgresql_adapter.rb b/lib/apartment/adapters/postgresql_adapter.rb index a2ca1163..17cbb892 100644 --- a/lib/apartment/adapters/postgresql_adapter.rb +++ b/lib/apartment/adapters/postgresql_adapter.rb @@ -121,14 +121,17 @@ def reset_sequence_names # There is `reset_sequence_name`, but that method actually goes to the database # to find out the new name. Therefore, we do this hack to only unset the name, # and it will be dynamically found the next time it is needed - ActiveRecord::Base.descendants - .select { |c| c.instance_variable_defined?(:@sequence_name) } - .reject { |c| c.instance_variable_defined?(:@explicit_sequence_name) && c.instance_variable_get(:@explicit_sequence_name) } - .each do |c| - # NOTE: due to this https://github.com/rails-on-services/apartment/issues/81 - # unreproduceable error we're checking before trying to remove it - c.remove_instance_variable :@sequence_name if c.instance_variable_defined?(:@sequence_name) - end + descendants_to_unset = ActiveRecord::Base.descendants + .select { |c| c.instance_variable_defined?(:@sequence_name) } + .reject do |c| + c.instance_variable_defined?(:@explicit_sequence_name) && + c.instance_variable_get(:@explicit_sequence_name) + end + descendants_to_unset.each do |c| + # NOTE: due to this https://github.com/rails-on-services/apartment/issues/81 + # unreproduceable error we're checking before trying to remove it + c.remove_instance_variable :@sequence_name if c.instance_variable_defined?(:@sequence_name) + end end end @@ -197,9 +200,11 @@ def pg_dump_schema # # @return {String} raw SQL contaning inserts with data from schema_migrations # + # rubocop:disable Layout/LineLength def pg_dump_schema_migrations_data with_pg_env { `pg_dump -a --inserts -t #{default_tenant}.schema_migrations -t #{default_tenant}.ar_internal_metadata #{dbname}` } end + # rubocop:enable Layout/LineLength # Temporary set Postgresql related environment variables if there are in @config # diff --git a/lib/apartment/custom_console.rb b/lib/apartment/custom_console.rb index bc3d0902..7b32a5b5 100644 --- a/lib/apartment/custom_console.rb +++ b/lib/apartment/custom_console.rb @@ -7,7 +7,9 @@ module CustomConsole begin require 'pry-rails' rescue LoadError + # rubocop:disable Layout/LineLength puts '[Failed to load pry-rails] If you want to use Apartment custom prompt you need to add pry-rails to your gemfile' + # rubocop:enable Layout/LineLength end desc = "Includes the current Rails environment and project folder name.\n" \ diff --git a/lib/generators/apartment/install/templates/apartment.rb b/lib/generators/apartment/install/templates/apartment.rb index ece13534..17f73c60 100644 --- a/lib/generators/apartment/install/templates/apartment.rb +++ b/lib/generators/apartment/install/templates/apartment.rb @@ -23,7 +23,8 @@ # You can make this dynamic by providing a Proc object to be called on migrations. # This object should yield either: # - an array of strings representing each Tenant name. - # - a hash which keys are tenant names, and values custom db config (must contain all key/values required in database.yml) + # - a hash which keys are tenant names, and values custom db config + # (must contain all key/values required in database.yml) # # config.tenant_names = lambda{ Customer.pluck(:tenant_name) } # config.tenant_names = ['tenant1', 'tenant2'] diff --git a/spec/adapters/jdbc_mysql_adapter_spec.rb b/spec/adapters/jdbc_mysql_adapter_spec.rb index 764893b3..2d0fb975 100644 --- a/spec/adapters/jdbc_mysql_adapter_spec.rb +++ b/spec/adapters/jdbc_mysql_adapter_spec.rb @@ -9,7 +9,9 @@ subject { Apartment::Tenant.jdbc_mysql_adapter config.symbolize_keys } def tenant_names - ActiveRecord::Base.connection.execute('SELECT schema_name FROM information_schema.schemata').collect { |row| row['schema_name'] } + ActiveRecord::Base.connection.execute('SELECT schema_name FROM information_schema.schemata').collect do |row| + row['schema_name'] + end end let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } } diff --git a/spec/adapters/mysql2_adapter_spec.rb b/spec/adapters/mysql2_adapter_spec.rb index ca3e577f..505b7d6b 100644 --- a/spec/adapters/mysql2_adapter_spec.rb +++ b/spec/adapters/mysql2_adapter_spec.rb @@ -9,7 +9,9 @@ subject(:adapter) { Apartment::Tenant.mysql2_adapter config } def tenant_names - ActiveRecord::Base.connection.execute('SELECT schema_name FROM information_schema.schemata').collect { |row| row[0] } + ActiveRecord::Base.connection.execute('SELECT schema_name FROM information_schema.schemata').collect do |row| + row[0] + end end let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } } diff --git a/spec/dummy/config/initializers/secret_token.rb b/spec/dummy/config/initializers/secret_token.rb index 2c7f52bd..1ba0d52f 100644 --- a/spec/dummy/config/initializers/secret_token.rb +++ b/spec/dummy/config/initializers/secret_token.rb @@ -6,4 +6,7 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. + +# rubocop:disable Layout/LineLength Dummy::Application.config.secret_token = '7d33999a86884f74c897c98ecca4277090b69e9f23df8d74bcadd57435320a7a16de67966f9b69d62e7d5ec553bd2febbe64c721e05bc1bc1e82c7a7d2395201' +# rubocop:enable Layout/LineLength diff --git a/spec/dummy/script/rails b/spec/dummy/script/rails index e1068b28..6c919a61 100755 --- a/spec/dummy/script/rails +++ b/spec/dummy/script/rails @@ -1,7 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. +# This command will automatically be run when you run "rails" with Rails 3 gems installed +# from the root of your application. APP_PATH = File.expand_path('../config/application', __dir__) require File.expand_path('../config/boot', __dir__) diff --git a/spec/dummy_engine/bin/rails b/spec/dummy_engine/bin/rails index 800e13a6..397f409e 100755 --- a/spec/dummy_engine/bin/rails +++ b/spec/dummy_engine/bin/rails @@ -1,7 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. +# This command will automatically be run when you run "rails" with Rails 4 gems installed +# from the root of your application. ENGINE_ROOT = File.expand_path('..', __dir__) ENGINE_PATH = File.expand_path('../lib/dummy_engine/engine', __dir__) diff --git a/spec/dummy_engine/config/initializers/apartment.rb b/spec/dummy_engine/config/initializers/apartment.rb index 466f3d87..a65748eb 100644 --- a/spec/dummy_engine/config/initializers/apartment.rb +++ b/spec/dummy_engine/config/initializers/apartment.rb @@ -36,7 +36,8 @@ # supply list of database names for migrations to run on # config.tenant_names = lambda{ ToDo_Tenant_Or_User_Model.pluck :database } - # Specify a connection other than ActiveRecord::Base for apartment to use (only needed if your models are using a different connection) + # Specify a connection other than ActiveRecord::Base for apartment to use + # (only needed if your models are using a different connection) # config.connection_class = ActiveRecord::Base end diff --git a/spec/examples/generic_adapter_custom_configuration_example.rb b/spec/examples/generic_adapter_custom_configuration_example.rb index 07e2c719..5abe5029 100644 --- a/spec/examples/generic_adapter_custom_configuration_example.rb +++ b/spec/examples/generic_adapter_custom_configuration_example.rb @@ -25,7 +25,9 @@ describe '#create' do it 'should establish_connection with the separate connection with expected args' do - expect(Apartment::Adapters::AbstractAdapter::SeparateDbConnectionHandler).to receive(:establish_connection).with(expected_args).and_call_original + expect(Apartment::Adapters::AbstractAdapter::SeparateDbConnectionHandler).to( + receive(:establish_connection).with(expected_args).and_call_original + ) # because we dont have another server to connect to it errors # what matters is establish_connection receives proper args @@ -35,7 +37,9 @@ describe '#drop' do it 'should establish_connection with the separate connection with expected args' do - expect(Apartment::Adapters::AbstractAdapter::SeparateDbConnectionHandler).to receive(:establish_connection).with(expected_args).and_call_original + expect(Apartment::Adapters::AbstractAdapter::SeparateDbConnectionHandler).to( + receive(:establish_connection).with(expected_args).and_call_original + ) # because we dont have another server to connect to it errors # what matters is establish_connection receives proper args From f1f739eb9e22774e5d02d3bd9d5d905e159e15ed Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Thu, 16 Jul 2020 12:39:22 +0800 Subject: [PATCH 6/6] diffend was causing some trouble updating the gems --- .travis.yml | 2 +- Gemfile | 2 +- gemfiles/rails_5_0.gemfile | 2 +- gemfiles/rails_5_1.gemfile | 2 +- gemfiles/rails_5_2.gemfile | 2 +- gemfiles/rails_6_0.gemfile | 2 +- gemfiles/rails_master.gemfile | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef952b31..784d4b5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ env: jobs: include: - name: Rubocop Lint - script: gem install perx-rubocop && rubocop + script: gem install rubocop allow_failures: - rvm: ruby-head diff --git a/Gemfile b/Gemfile index fa74281e..0949319d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -source 'https://my.diffend.io/protect/gems' +source 'http://rubygems.org' gemspec diff --git a/gemfiles/rails_5_0.gemfile b/gemfiles/rails_5_0.gemfile index e963b5b3..37dc042b 100644 --- a/gemfiles/rails_5_0.gemfile +++ b/gemfiles/rails_5_0.gemfile @@ -2,8 +2,8 @@ source "http://rubygems.org" -gem "perx-rubocop", "~> 0.0.3" gem "rails", "~> 5.0.0" +gem "rubocop" group :local do gem "guard-rspec", "~> 4.2" diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile index 8785b959..59af05f8 100644 --- a/gemfiles/rails_5_1.gemfile +++ b/gemfiles/rails_5_1.gemfile @@ -2,8 +2,8 @@ source "http://rubygems.org" -gem "perx-rubocop", "~> 0.0.3" gem "rails", "~> 5.1.0" +gem "rubocop" group :local do gem "guard-rspec", "~> 4.2" diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile index 1afc645b..18d8952a 100644 --- a/gemfiles/rails_5_2.gemfile +++ b/gemfiles/rails_5_2.gemfile @@ -2,8 +2,8 @@ source "http://rubygems.org" -gem "perx-rubocop", "~> 0.0.3" gem "rails", "~> 5.2.0" +gem "rubocop" group :local do gem "guard-rspec", "~> 4.2" diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile index 6c3d3968..6d23e4aa 100644 --- a/gemfiles/rails_6_0.gemfile +++ b/gemfiles/rails_6_0.gemfile @@ -2,8 +2,8 @@ source "http://rubygems.org" -gem "perx-rubocop", "~> 0.0.3" gem "rails", "~> 6.0.0" +gem "rubocop" group :local do gem "guard-rspec", "~> 4.2" diff --git a/gemfiles/rails_master.gemfile b/gemfiles/rails_master.gemfile index f2add08a..82ad9191 100644 --- a/gemfiles/rails_master.gemfile +++ b/gemfiles/rails_master.gemfile @@ -2,8 +2,8 @@ source "http://rubygems.org" -gem "perx-rubocop", "~> 0.0.3" gem "rails", git: "https://github.com/rails/rails.git" +gem "rubocop" group :local do gem "guard-rspec", "~> 4.2"