Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ inherit_from:
- .rubocop_performance.yml
- .rubocop_rspec.yml
- .rubocop_thread_safety.yml
- .rubocop_todo.yml

require:
- rubocop-packaging
Expand All @@ -21,6 +20,11 @@ AllCops:
DisplayCopNames: true # Display the name of the failing cops
NewCops: enable

# Intentionally disabled
# There are several cases with already established method signatires
Style/OptionalArguments:
Enabled: false

# It's a matter of taste
Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation
Expand Down
122 changes: 0 additions & 122 deletions .rubocop_todo.yml

This file was deleted.

2 changes: 1 addition & 1 deletion lib/dynamoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
require 'dynamoid/railtie' if defined?(Rails)

module Dynamoid
extend self
extend self # rubocop:disable Style/ModuleFunction

def configure
block_given? ? yield(Dynamoid::Config) : Dynamoid::Config
Expand Down
4 changes: 1 addition & 3 deletions lib/dynamoid/adapter_plugin/aws_sdk_v3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ def connection_config
# Return the client object.
#
# @since 1.0.0
def client
@client
end
attr_reader :client

# Puts multiple items in one table
#
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Config
'dynamoid'
end

extend self
extend self # rubocop:disable Style/ModuleFunction

extend Options
include ActiveModel::Observing if defined?(ActiveModel::Observing)
Expand Down
14 changes: 5 additions & 9 deletions lib/dynamoid/dirty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def changes
#
# @return [ActiveSupport::HashWithIndifferentAccess]
def previous_changes
@previously_changed ||= ActiveSupport::HashWithIndifferentAccess.new
@previous_changes ||= ActiveSupport::HashWithIndifferentAccess.new
end

# Returns a hash of the attributes with unsaved changes indicating their original
Expand All @@ -140,14 +140,14 @@ def changed_attributes

# Clear all dirty data: current changes and previous changes.
def clear_changes_information
@previously_changed = ActiveSupport::HashWithIndifferentAccess.new
@previous_changes = ActiveSupport::HashWithIndifferentAccess.new
@attributes_changed_by_setter = ActiveSupport::HashWithIndifferentAccess.new
@attributes_from_database = HashWithIndifferentAccess.new(DeepDupper.dup_attributes(@attributes, self.class))
end

# Clears dirty data and moves +changes+ to +previous_changes+.
def changes_applied
@previously_changed = changes
@previous_changes = changes
@attributes_changed_by_setter = ActiveSupport::HashWithIndifferentAccess.new
@attributes_from_database = HashWithIndifferentAccess.new(DeepDupper.dup_attributes(@attributes, self.class))
end
Expand Down Expand Up @@ -248,12 +248,8 @@ def attribute_change(name)
def attribute_will_change!(name)
return if attribute_changed?(name)

begin
value = read_attribute(name)
value = value.clone if value.duplicable?
rescue TypeError, NoMethodError
end

value = read_attribute(name)
value = value.clone if value.duplicable?
set_attribute_was(name, value)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def upsert(hash_key_value, range_key_value = nil, attrs = {}, conditions = {})
# @return [Model class] self
def inc(hash_key_value, range_key_value = nil, counters)
# It's similar to Rails' #update_counters.
Inc.call(self, hash_key_value, range_key_value, counters)
Inc.call(self, hash_key_value, range_key_value, **counters)
self
end

Expand Down
8 changes: 3 additions & 5 deletions lib/dynamoid/persistence/inc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ module Dynamoid
module Persistence
# @private
class Inc
def self.call(model_class, partition_key, sort_key = nil, counters) # rubocop:disable Style/OptionalArguments
new(model_class, partition_key, sort_key, counters).call
def self.call(model_class, partition_key, sort_key, **counters)
new(model_class, partition_key, sort_key, **counters).call
end

# rubocop:disable Style/OptionalArguments
def initialize(model_class, partition_key, sort_key = nil, counters)
def initialize(model_class, partition_key, sort_key, **counters)
@model_class = model_class
@partition_key = partition_key
@sort_key = sort_key
@counters = counters
@touch = @counters.delete(:touch)
end
# rubocop:enable Style/OptionalArguments

def call
validate_primary_key!
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/persistence/update_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def call

raw_attributes = update_item
@model_class.new(undump_attributes(raw_attributes))
rescue Dynamoid::Errors::ConditionalCheckFailedException
rescue Dynamoid::Errors::ConditionalCheckFailedException # rubocop:disable Lint/SuppressedException
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/persistence/upsert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def call

raw_attributes = update_item
@model_class.new(undump_attributes(raw_attributes))
rescue Dynamoid::Errors::ConditionalCheckFailedException
rescue Dynamoid::Errors::ConditionalCheckFailedException # rubocop:disable Lint/SuppressedException
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/transactions/mutation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def create(model_class, attributes = {}, &block)
# @param range_key [Scalar value] range key value (optional)
# @param attributes [Hash]
# @return [nil]
def upsert(model_class, hash_key, range_key = nil, attributes) # rubocop:disable Style/OptionalArguments
def upsert(model_class, hash_key, range_key = nil, attributes)
action = Upsert.new(model_class, hash_key, range_key, attributes)
register_action action
end
Expand Down
12 changes: 6 additions & 6 deletions spec/dynamoid/adapter_plugin/aws_sdk_v3/create_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
let(:table_description) { double('table_description', table_status: 'ACTIVE') }

describe 'call' do
context 'table properties' do
context 'with table properties' do
it 'has the correct table name' do
expect(client).to receive(:create_table)
.with(hash_including(table_name: :dogs))
Expand All @@ -42,7 +42,7 @@
described_class.new(client, :dogs, :id, options).call
end

context 'on demand' do
context 'when on demand' do
let(:options) do
{ billing_mode: :on_demand }
end
Expand All @@ -65,7 +65,7 @@
end
end

context 'key schema' do
context 'with key schema' do
it 'defines a simple primary key' do
expect(client).to receive(:create_table)
.with(hash_including(key_schema: [hash_including(attribute_name: 'id', key_type: 'HASH')]))
Expand Down Expand Up @@ -110,7 +110,7 @@
end
end

context 'local secondary index' do
context 'with local secondary index' do
let(:options) do
super().merge(local_secondary_indexes: [index])
end
Expand Down Expand Up @@ -147,7 +147,7 @@
end
end

context 'global secondary index' do
context 'with global secondary index' do
let(:options) do
super().merge(global_secondary_indexes: [index])
end
Expand Down Expand Up @@ -197,7 +197,7 @@
described_class.new(client, :dogs, :id, options).call
end

context 'on demand' do
context 'when on demand' do
let(:options) do
super().merge(billing_mode: :on_demand)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

describe Dynamoid::AdapterPlugin::AwsSdkV3::UntilPastTableStatus do
describe 'call' do
context 'table creation' do
context 'with table creation' do
let(:client) { double('client') }
let(:response_creating) { double('response#creating', table: creating_table) }
let(:response_active) { double('response#active', table: active_table) }
Expand Down
Loading
Loading