diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 61e7fbdc..4cf4f2d9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-03-18 03:26:00 UTC using RuboCop version 0.89.1. +# on 2021-03-21 03:46:53 UTC using RuboCop version 1.11.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 @@ -15,7 +15,18 @@ Gemspec/OrderedDependencies: - 'paper_trail.gemspec' # Offense count: 4 -# Configuration parameters: IgnoredMethods. +# Cop supports --auto-correct. +# Configuration parameters: AllowedMethods. +# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? +Lint/RedundantSafeNavigation: + Exclude: + - 'lib/paper_trail/events/base.rb' + - 'lib/paper_trail/queries/versions/where_object_changes.rb' + - 'lib/paper_trail/queries/versions/where_object_changes_from.rb' + - 'lib/paper_trail/version_concern.rb' + +# Offense count: 5 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: Max: 19 # Goal: the default (17?) @@ -36,6 +47,26 @@ Naming/MemoizedInstanceVariableName: Exclude: - 'lib/paper_trail/model_config.rb' +# Offense count: 1 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. +# SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 +Naming/VariableNumber: + Exclude: + - 'spec/dummy_app/app/models/person.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Performance/BlockGivenWithExplicitBlock: + Exclude: + - 'lib/paper_trail.rb' + +# Offense count: 1 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'spec/models/version_spec.rb' + # Offense count: 115 # Configuration parameters: Prefixes. # Prefixes: when, with, without @@ -62,10 +93,6 @@ Rails/ApplicationController: Exclude: - 'spec/dummy_app/app/controllers/test_controller.rb' -# We want this, but not until we drop support for ruby 2.4 -Style/HashTransformKeys: - Enabled: false - # Offense count: 56 # Cop supports --auto-correct. Rails/ApplicationRecord: @@ -122,7 +149,11 @@ Rails/WhereNot: Exclude: - 'lib/paper_trail/version_concern.rb' -# We want this, but not until we drop support for ruby 2.4 -Style/HashTransformValues: +RSpec/FilePath: Exclude: - - 'lib/paper_trail/events/destroy.rb' + - 'spec/paper_trail/model_spec.rb' + - 'spec/paper_trail/serializer_spec.rb' + +Style/ClassEqualityComparison: + Exclude: + - 'lib/paper_trail/attribute_serializers/attribute_serializer_factory.rb' diff --git a/lib/paper_trail/events/destroy.rb b/lib/paper_trail/events/destroy.rb index 1b9359a0..236a10fc 100644 --- a/lib/paper_trail/events/destroy.rb +++ b/lib/paper_trail/events/destroy.rb @@ -35,7 +35,7 @@ module PaperTrail # # @override def changes_in_latest_version - @record.attributes.map { |attr, value| [attr, [value, nil]] }.to_h + @record.attributes.transform_values { |value| [value, nil] } end end end diff --git a/paper_trail.gemspec b/paper_trail.gemspec index a8d517b7..c67c5aa0 100644 --- a/paper_trail.gemspec +++ b/paper_trail.gemspec @@ -65,11 +65,11 @@ has been destroyed. s.add_development_dependency "rake", "~> 13.0" s.add_development_dependency "rspec-rails", "~> 4.0" - s.add_development_dependency "rubocop", "~> 0.89.1" - s.add_development_dependency "rubocop-rails", "~> 2.8" + s.add_development_dependency "rubocop", "~> 1.11.0" + s.add_development_dependency "rubocop-rails", "~> 2.9.1" s.add_development_dependency "rubocop-packaging", "~> 0.5.1" - s.add_development_dependency "rubocop-performance", "~> 1.7.1" - s.add_development_dependency "rubocop-rspec", "~> 1.42.0" + s.add_development_dependency "rubocop-performance", "~> 1.10.1" + s.add_development_dependency "rubocop-rspec", "~> 2.2.0" # ## Database Adapters # diff --git a/spec/paper_trail/serializer_spec.rb b/spec/paper_trail/serializer_spec.rb index 6ad34b1f..3ee71366 100644 --- a/spec/paper_trail/serializer_spec.rb +++ b/spec/paper_trail/serializer_spec.rb @@ -69,7 +69,7 @@ RSpec.describe(PaperTrail, versioning: true) do original_attributes = PaperTrail::Events::Base. new(customer, false). send(:nonskipped_attributes_before_change, false). - reject { |_k, v| v.nil? } + compact customer.update(name: "Some more text.") expect(customer.versions.length).to(eq(2)) expect(customer.versions[0].reify).to(be_nil) diff --git a/spec/paper_trail/serializers/custom_yaml_serializer_spec.rb b/spec/paper_trail/serializers/custom_yaml_serializer_spec.rb index fd2c5e30..2a14a329 100644 --- a/spec/paper_trail/serializers/custom_yaml_serializer_spec.rb +++ b/spec/paper_trail/serializers/custom_yaml_serializer_spec.rb @@ -15,7 +15,7 @@ module CustomYamlSerializer end def self.dump(object) - object.is_a?(Hash) ? super(object.reject { |_k, v| v.nil? }) : super + object.is_a?(Hash) ? super(object.compact) : super end end @@ -40,7 +40,7 @@ RSpec.describe CustomYamlSerializer do describe ".dump" do it("serializes Ruby to YAML, removing pairs with nil values") do expect(described_class.dump(word_hash)).to eq( - word_hash.reject { |_k, v| v.nil? }.to_yaml + word_hash.compact.to_yaml ) end end diff --git a/spec/support/custom_json_serializer.rb b/spec/support/custom_json_serializer.rb index 8b7b1e5b..33206b77 100644 --- a/spec/support/custom_json_serializer.rb +++ b/spec/support/custom_json_serializer.rb @@ -10,6 +10,6 @@ module CustomJsonSerializer end def self.dump(object) - object.is_a?(Hash) ? super(object.reject { |_k, v| v.nil? }) : super + object.is_a?(Hash) ? super(object.compact) : super end end