From 205728aeaba7c6242b91cd2a852ff20389885981 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 15 Jun 2025 13:11:17 +0200 Subject: [PATCH] Minor improvements - Update RuboCop config - Remove conditional check on `ActiveModel::Dirty.changes_applied`, since this method has been added in AM 4.1.0 and the minimum required AM version is 7.0 Ref: - https://github.com/rails/rails/blob/v4.1.8/activemodel/CHANGELOG.md#rails-410-april-8-2014 --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 15 +++++---------- lib/hawk/model/active.rb | 16 ++++------------ 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index bfa8f5c..48613f1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,9 @@ AllCops: Layout/LineLength: Enabled: false +Naming/PredicateMethod: + AllowBangMethods: true + Rails/Delegate: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 72b783e..4d59a4e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.72.2. +# using RuboCop version 1.76.1. # 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 @@ -35,11 +35,6 @@ Lint/MissingSuper: Exclude: - 'lib/hawk/model/collection.rb' -Lint/ShadowingOuterLocalVariable: - Exclude: - - 'lib/hawk/http.rb' - - 'lib/hawk/model/finder.rb' - # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 40 @@ -72,11 +67,11 @@ Naming/MemoizedInstanceVariableName: - 'lib/hawk/model/proxy.rb' # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs. -# NamePrefix: is_, has_, have_ -# ForbiddenPrefixes: is_, has_, have_ +# NamePrefix: is_, has_, have_, does_ +# ForbiddenPrefixes: is_, has_, have_, does_ # AllowedMethods: is_a? # MethodDefinitionMacros: define_method, define_singleton_method -Naming/PredicateName: +Naming/PredicatePrefix: Exclude: - 'lib/hawk/model/association.rb' @@ -129,7 +124,7 @@ Style/FormatString: - 'lib/hawk/rake/default_task.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. +# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns. # SupportedStyles: annotated, template, unannotated # AllowedMethods: redirect Style/FormatStringToken: diff --git a/lib/hawk/model/active.rb b/lib/hawk/model/active.rb index 6b47a61..4e056f8 100644 --- a/lib/hawk/model/active.rb +++ b/lib/hawk/model/active.rb @@ -46,18 +46,10 @@ def write_attribute(name, value) super end - if ActiveModel::Dirty.instance_methods.include?(:changes_applied) - def save! - persist! - changes_applied - true - end - else - def save! - persist! - @changed_attributes&.clear - true - end + def save! + persist! + changes_applied + true end def save