Skip to content

Commit

Permalink
Rubocop fixes
Browse files Browse the repository at this point in the history
I can't wait until Rails ships with Rubocop.
  • Loading branch information
lcreid committed Oct 13, 2024
1 parent 7bd3e80 commit 85403b0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions demo/config/initializers/filter_parameter_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
Rails.application.config.filter_parameters += %i[
passw secret token _key crypt salt certificate otp ssn
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
def up
return unless table_exists?(:active_storage_blobs)

unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string
return if column_exists?(:active_storage_blobs, :service_name)

if configured_service = ActiveStorage::Blob.service.name
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
end
add_column :active_storage_blobs, :service_name, :string

change_column :active_storage_blobs, :service_name, :string, null: false
if (configured_service = ActiveStorage::Blob.service.name)
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) # rubocop:disable Rails/SkipsModelValidations
end

change_column :active_storage_blobs, :service_name, :string, null: false
end

def down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ def change
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
t.string :variation_digest, null: false

t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end

private
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end

def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
def primary_key_type
config = Rails.configuration.generators
config.options[config.orm][:primary_key_type] || :primary_key
end

def blobs_primary_key_type
pkey_name = connection.primary_key(:active_storage_blobs)
pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name }
pkey_column.bigint? ? :bigint : pkey_column.type
end
end
4 changes: 2 additions & 2 deletions gemfiles/6.1.gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
gems = "#{__dir__}/common.gemfile"
eval File.read(gems), binding, gems # rubocop: disable Security/Eval

gem "base64" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "base64" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "logger" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "rails", "~> 6.1.0"
gem "sqlite3", "~> 1.4"
6 changes: 3 additions & 3 deletions gemfiles/7.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
gems = "#{__dir__}/common.gemfile"
eval File.read(gems), binding, gems # rubocop: disable Security/Eval

gem "base64" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "base64" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "logger" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "rails", "~> 7.0.2"
gem "sqlite3", "~> 1.4"
gem "sprockets-rails", require: "sprockets/railtie"
gem "sqlite3", "~> 1.4"
2 changes: 1 addition & 1 deletion gemfiles/7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "rails", "~> 7.1.0"
gem "sqlite3", "~> 1.4"
gem "sprockets-rails", require: "sprockets/railtie"
gem "sqlite3", "~> 1.4"
2 changes: 1 addition & 1 deletion gemfiles/7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "rails", "~> 7.2.0"
gem "sqlite3"
gem "sprockets-rails", require: "sprockets/railtie"
gem "sqlite3"
2 changes: 1 addition & 1 deletion gemfiles/edge.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
gem "sqlite3"
gem "sprockets-rails", require: "sprockets/railtie"
gem "sqlite3"
2 changes: 1 addition & 1 deletion test/bootstrap_fields_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class BootstrapFieldsTest < ActionView::TestCase
<input min="0" max="80" class="form-range" id="user_misc" name="user[misc]" type="range" />
</div>
HTML
assert_equivalent_html expected, @builder.range_field(:misc, min: 0, max: 80)
assert_equivalent_html expected, @builder.range_field(:misc, min: 0, max: 80)
end

test "search fields are wrapped correctly" do
Expand Down

0 comments on commit 85403b0

Please sign in to comment.