diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ff1080..61284db 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -13,7 +13,7 @@ Metrics/AbcSize: # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Max: 44 + Max: 43 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: @@ -87,14 +87,6 @@ Style/CommentedKeyword: Style/Documentation: Enabled: false -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. -Style/GuardClause: - Exclude: - - 'lib/active_record/connection_adapters/chronomodel_adapter.rb' - - 'lib/chrono_model/adapter/migrations.rb' - - 'lib/chrono_model/time_machine.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, Autocorrect. # SupportedStyles: module_function, extend_self, forbidden diff --git a/lib/active_record/connection_adapters/chronomodel_adapter.rb b/lib/active_record/connection_adapters/chronomodel_adapter.rb index 6c7575a..9626377 100644 --- a/lib/active_record/connection_adapters/chronomodel_adapter.rb +++ b/lib/active_record/connection_adapters/chronomodel_adapter.rb @@ -41,11 +41,9 @@ def chronomodel_connection(config) # :nodoc: adapter rescue ::PG::Error => e - if e.message.include?(conn_params[:dbname]) - raise ActiveRecord::NoDatabaseError - else - raise - end + raise ActiveRecord::NoDatabaseError if e.message.include?(conn_params[:dbname]) + + raise end end end diff --git a/lib/chrono_model/adapter/migrations.rb b/lib/chrono_model/adapter/migrations.rb index 001f2c7..6280c7e 100644 --- a/lib/chrono_model/adapter/migrations.rb +++ b/lib/chrono_model/adapter/migrations.rb @@ -201,9 +201,9 @@ def chrono_make_temporal_table(table_name, options) # Optionally copy the plain table data, setting up history # retroactively. # - if options[:copy_data] - chrono_copy_temporal_to_history(table_name, options) - end + return unless options[:copy_data] + + chrono_copy_temporal_to_history(table_name, options) end def chrono_copy_temporal_to_history(table_name, options) diff --git a/lib/chrono_model/time_machine.rb b/lib/chrono_model/time_machine.rb index 66b96f1..8564fe2 100644 --- a/lib/chrono_model/time_machine.rb +++ b/lib/chrono_model/time_machine.rb @@ -74,9 +74,9 @@ def inherited(subclass) # Sadly, we can't avoid it by calling +.history?+, because in the # subclass the HistoryModel hasn't been included yet. # - unless subclass.name.nil? - ChronoModel::TimeMachine.define_history_model_for(subclass) - end + return if subclass.name.nil? + + ChronoModel::TimeMachine.define_history_model_for(subclass) end end end