diff --git a/.rubocop.yml b/.rubocop.yml index d38f97fdb..45db10559 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -142,9 +142,6 @@ Layout/EmptyLinesAroundClassBody: Layout/EmptyLinesAroundModuleBody: Enabled: false -Style/IfUnlessModifier: - Enabled: false - Performance/CollectionLiteralInLoop: Exclude: - 'spec/mongoid/association/embedded/embeds_many/proxy_spec.rb' @@ -153,6 +150,9 @@ Performance/CollectionLiteralInLoop: - 'spec/mongoid/criteria/queryable/selectable_spec.rb' - 'spec/mongoid/criteria/queryable/selector_spec.rb' +Style/IfUnlessModifier: + Enabled: false + # -------------------------------------------------- # These cops are intentionally disabled due to incompatibility. @@ -215,6 +215,9 @@ Naming/PredicateName: - has_attribute? - has_attribute_before_type_cast? +RSpec/IndexedLet: + Enabled: false + RSpec/NotToNot: EnforcedStyle: to_not diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 96194f50c..af5d756b5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 1000` -# on 2024-01-16 04:19:18 UTC using RuboCop version 1.60.0. +# on 2024-05-06 14:01:50 UTC using RuboCop version 1.63.4. # 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 @@ -21,7 +21,7 @@ Lint/SelfAssignment: - 'spec/integration/associations/has_one_spec.rb' - 'spec/mongoid/association/embedded/embeds_one/proxy_spec.rb' -# Offense count: 108 +# Offense count: 110 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 154 @@ -37,22 +37,22 @@ Metrics/BlockLength: Metrics/BlockNesting: Max: 6 -# Offense count: 17 +# Offense count: 18 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: Max: 337 -# Offense count: 51 +# Offense count: 52 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 33 -# Offense count: 184 +# Offense count: 185 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 87 -# Offense count: 22 +# Offense count: 21 # Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: Max: 330 @@ -63,7 +63,7 @@ Metrics/ParameterLists: MaxOptionalParameters: 4 Max: 6 -# Offense count: 40 +# Offense count: 41 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 20 @@ -262,7 +262,15 @@ RSpec/DescribeClass: - 'spec/mongoid/railties/console_sandbox_spec.rb' - 'spec/mongoid/tasks/database_rake_spec.rb' -# Offense count: 124 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. +# DisallowedExamples: works +RSpec/ExampleWording: + Exclude: + - 'spec/mongoid/persistable/updatable_spec.rb' + +# Offense count: 120 RSpec/ExpectInHook: Exclude: - 'spec/integration/associations/embedded_spec.rb' @@ -301,14 +309,13 @@ RSpec/ExpectInHook: - 'spec/mongoid/serializable_spec.rb' - 'spec/mongoid/tasks/database_rake_spec.rb' - 'spec/mongoid/tasks/encryption_spec.rb' - - 'spec/mongoid/validatable/associated_spec.rb' - 'spec/mongoid/validatable/presence_spec.rb' - 'spec/support/immutable_ids.rb' # Offense count: 24 # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. # Include: **/*_spec*rb*, **/spec/**/* -RSpec/SpecFilePathFormat: +RSpec/FilePath: Exclude: - 'spec/integration/atomic/modifiers_spec.rb' - 'spec/integration/bson_regexp_raw_spec.rb' @@ -335,43 +342,14 @@ RSpec/SpecFilePathFormat: - 'spec/mongoid/validatable/uniqueness_spec.rb' - 'spec/mongoid/version_spec.rb' -# Offense count: 24 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/SpecFilePathSuffix: - Exclude: - - 'spec/integration/atomic/modifiers_spec.rb' - - 'spec/integration/bson_regexp_raw_spec.rb' - - 'spec/integration/document_spec.rb' - - 'spec/mongoid/association/auto_save_spec.rb' - - 'spec/mongoid/association/counter_cache_spec.rb' - - 'spec/mongoid/association/eager_spec.rb' - - 'spec/mongoid/clients/transactions_spec.rb' - - 'spec/mongoid/criteria/queryable/extensions/boolean_spec.rb' - - 'spec/mongoid/criteria/queryable/extensions/numeric_spec.rb' - - 'spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb' - - 'spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb' - - 'spec/mongoid/criteria/queryable/queryable_spec.rb' - - 'spec/mongoid/extensions/binary_spec.rb' - - 'spec/mongoid/extensions/boolean_spec.rb' - - 'spec/mongoid/extensions/raw_value_spec.rb' - - 'spec/mongoid/extensions/stringified_symbol_spec.rb' - - 'spec/mongoid/loading_spec.rb' - - 'spec/mongoid/validatable/associated_spec.rb' - - 'spec/mongoid/validatable/format_spec.rb' - - 'spec/mongoid/validatable/length_spec.rb' - - 'spec/mongoid/validatable/numericality_spec.rb' - - 'spec/mongoid/validatable/presence_spec.rb' - - 'spec/mongoid/validatable/uniqueness_spec.rb' - - 'spec/mongoid/version_spec.rb' - -# Offense count: 18 +# Offense count: 21 RSpec/IteratedExpectation: Exclude: - 'spec/mongoid/association/referenced/belongs_to/eager_spec.rb' - 'spec/mongoid/association/referenced/has_many/eager_spec.rb' - 'spec/mongoid/association/referenced/has_many/enumerable_spec.rb' - 'spec/mongoid/association/referenced/has_one/eager_spec.rb' + - 'spec/mongoid/clients_spec.rb' - 'spec/mongoid/contextual/memory_spec.rb' - 'spec/mongoid/contextual/mongo_spec.rb' - 'spec/mongoid/criteria_spec.rb' @@ -511,7 +489,7 @@ RSpec/LetSetup: - 'spec/mongoid/touchable_spec.rb' - 'spec/mongoid/validatable/uniqueness_spec.rb' -# Offense count: 308 +# Offense count: 306 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -546,7 +524,7 @@ RSpec/NamedSubject: RSpec/NestedGroups: Max: 13 -# Offense count: 31 +# Offense count: 32 # Configuration parameters: AllowedPatterns. # AllowedPatterns: ^expect_, ^assert_ RSpec/NoExpectationExample: @@ -561,6 +539,7 @@ RSpec/NoExpectationExample: - 'spec/mongoid/collection_configurable_spec.rb' - 'spec/mongoid/document_spec.rb' - 'spec/mongoid/errors/mongoid_error_spec.rb' + - 'spec/mongoid/inspectable_spec.rb' - 'spec/mongoid/persistence_context_spec.rb' - 'spec/mongoid/scopable_spec.rb' - 'spec/mongoid/tasks/database_rake_spec.rb' @@ -573,18 +552,52 @@ RSpec/OverwritingSetup: - 'spec/mongoid/interceptable_spec.rb' - 'spec/mongoid/serializable_spec.rb' -# Offense count: 17 +# Offense count: 3 RSpec/PendingWithoutReason: Exclude: + - 'spec/mongoid/criteria/queryable/aggregable_spec.rb' + - 'spec/mongoid/serializable_spec.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +RSpec/RedundantPredicateMatcher: + Exclude: + - 'spec/mongoid/copyable_spec.rb' + - 'spec/mongoid/document_spec.rb' + - 'spec/mongoid/equality_spec.rb' + +# Offense count: 105 +RSpec/RemoveConst: + Exclude: + - 'spec/integration/discriminator_key_spec.rb' + - 'spec/mongoid/association/auto_save_spec.rb' - 'spec/mongoid/association/embedded/embedded_in_spec.rb' - - 'spec/mongoid/association/embedded/embeds_many_spec.rb' - - 'spec/mongoid/association/embedded/embeds_one_spec.rb' + - 'spec/mongoid/association/embedded/embeds_many/proxy_spec.rb' + - 'spec/mongoid/association/macros_spec.rb' + - 'spec/mongoid/association/options_spec.rb' + - 'spec/mongoid/association/referenced/belongs_to/proxy_spec.rb' - 'spec/mongoid/association/referenced/belongs_to_spec.rb' - 'spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb' - 'spec/mongoid/association/referenced/has_many_spec.rb' + - 'spec/mongoid/association/referenced/has_one/proxy_spec.rb' - 'spec/mongoid/association/referenced/has_one_spec.rb' - - 'spec/mongoid/criteria/queryable/aggregable_spec.rb' - - 'spec/mongoid/serializable_spec.rb' + - 'spec/mongoid/association/syncable_spec.rb' + - 'spec/mongoid/clients_spec.rb' + - 'spec/mongoid/collection_configurable_spec.rb' + - 'spec/mongoid/copyable_spec.rb' + - 'spec/mongoid/criteria/includable_spec.rb' + - 'spec/mongoid/criteria/queryable/options_spec.rb' + - 'spec/mongoid/criteria/queryable/selectable_spec.rb' + - 'spec/mongoid/criteria/queryable/selectable_where_spec.rb' + - 'spec/mongoid/criteria/queryable/selector_spec.rb' + - 'spec/mongoid/document_spec.rb' + - 'spec/mongoid/fields/standard_spec.rb' + - 'spec/mongoid/scopable_spec.rb' + - 'spec/mongoid/stateful_spec.rb' + - 'spec/mongoid/tasks/database_spec.rb' + - 'spec/mongoid/timestamps/timeless_spec.rb' + - 'spec/mongoid/validatable/numericality_spec.rb' + - 'spec/support/feature_sandbox.rb' # Offense count: 17 RSpec/RepeatedDescription: @@ -669,6 +682,7 @@ RSpec/ScatteredLet: - 'spec/mongoid/scopable_spec.rb' # Offense count: 67 +# This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredSetup: Exclude: - 'spec/integration/stringified_symbol_field_spec.rb' @@ -680,7 +694,37 @@ RSpec/ScatteredSetup: - 'spec/mongoid/copyable_spec.rb' - 'spec/mongoid/persistable/deletable_spec.rb' -# Offense count: 12 +# Offense count: 24 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - 'spec/integration/atomic/modifiers_spec.rb' + - 'spec/integration/bson_regexp_raw_spec.rb' + - 'spec/integration/document_spec.rb' + - 'spec/mongoid/association/auto_save_spec.rb' + - 'spec/mongoid/association/counter_cache_spec.rb' + - 'spec/mongoid/association/eager_spec.rb' + - 'spec/mongoid/clients/transactions_spec.rb' + - 'spec/mongoid/criteria/queryable/extensions/boolean_spec.rb' + - 'spec/mongoid/criteria/queryable/extensions/numeric_spec.rb' + - 'spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb' + - 'spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb' + - 'spec/mongoid/criteria/queryable/queryable_spec.rb' + - 'spec/mongoid/extensions/binary_spec.rb' + - 'spec/mongoid/extensions/boolean_spec.rb' + - 'spec/mongoid/extensions/raw_value_spec.rb' + - 'spec/mongoid/extensions/stringified_symbol_spec.rb' + - 'spec/mongoid/loading_spec.rb' + - 'spec/mongoid/validatable/associated_spec.rb' + - 'spec/mongoid/validatable/format_spec.rb' + - 'spec/mongoid/validatable/length_spec.rb' + - 'spec/mongoid/validatable/numericality_spec.rb' + - 'spec/mongoid/validatable/presence_spec.rb' + - 'spec/mongoid/validatable/uniqueness_spec.rb' + - 'spec/mongoid/version_spec.rb' + +# Offense count: 8 RSpec/StubbedMock: Exclude: - 'spec/mongoid/clients_spec.rb' @@ -688,7 +732,6 @@ RSpec/StubbedMock: - 'spec/mongoid/persistence_context_spec.rb' - 'spec/mongoid/tasks/database_spec.rb' - 'spec/mongoid/tasks/encryption_spec.rb' - - 'spec/mongoid/validatable/associated_spec.rb' # Offense count: 26 RSpec/SubjectDeclaration: @@ -698,7 +741,7 @@ RSpec/SubjectDeclaration: - 'spec/mongoid/collection_configurable_spec.rb' - 'spec/mongoid/contextual/mongo/documents_loader_spec.rb' -# Offense count: 27 +# Offense count: 23 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -714,10 +757,10 @@ RSpec/VerifiedDoubles: - 'spec/mongoid/persistence_context_spec.rb' - 'spec/mongoid/tasks/database_spec.rb' - 'spec/mongoid/threaded_spec.rb' - - 'spec/mongoid/validatable/associated_spec.rb' - 'spec/rails/mongoid_spec.rb' # Offense count: 11 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowToTime. # SupportedStyles: strict, flexible Rails/Date: @@ -748,6 +791,19 @@ Rails/Delegate: - 'lib/mongoid/findable.rb' - 'lib/mongoid/scopable.rb' +# Offense count: 11 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns. +# AllowedMethods: order, limit, select, lock +Rails/FindEach: + Exclude: + - 'spec/mongoid/association/referenced/belongs_to/eager_spec.rb' + - 'spec/mongoid/association/referenced/has_and_belongs_to_many/eager_spec.rb' + - 'spec/mongoid/association/referenced/has_many/eager_spec.rb' + - 'spec/mongoid/association/referenced/has_many/proxy_spec.rb' + - 'spec/mongoid/association/referenced/has_one/eager_spec.rb' + - 'spec/mongoid/criteria_projection_spec.rb' + # Offense count: 91 # Configuration parameters: Include. # Include: spec/**/*.rb, test/**/*.rb @@ -767,6 +823,24 @@ Rails/I18nLocaleAssignment: - 'spec/mongoid/validatable/uniqueness_spec.rb' - 'spec/support/macros.rb' +# Offense count: 28 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: ActionMailer::Preview, ActiveSupport::TimeZone +Rails/RedundantActiveRecordAllMethod: + Exclude: + - 'spec/integration/criteria/time_with_zone_spec.rb' + - 'spec/mongoid/association/referenced/belongs_to/eager_spec.rb' + - 'spec/mongoid/association/referenced/has_and_belongs_to_many/eager_spec.rb' + - 'spec/mongoid/association/referenced/has_many/eager_spec.rb' + - 'spec/mongoid/association/referenced/has_one/eager_spec.rb' + - 'spec/mongoid/contextual/aggregable/memory_spec.rb' + - 'spec/mongoid/contextual/memory_spec.rb' + - 'spec/mongoid/criteria/includable_spec.rb' + - 'spec/mongoid/criteria/queryable/selectable_logical_spec.rb' + - 'spec/mongoid/criteria_spec.rb' + - 'spec/mongoid/serializable_spec.rb' + # Offense count: 133 # Configuration parameters: ForbiddenMethods, AllowedMethods. # ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all @@ -795,7 +869,7 @@ Rails/SkipsModelValidations: - 'spec/mongoid/touchable_spec.rb' - 'spec/support/models/server.rb' -# Offense count: 151 +# Offense count: 134 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible @@ -805,7 +879,6 @@ Rails/TimeZone: - 'lib/mongoid/extensions/date.rb' - 'lib/mongoid/extensions/string.rb' - 'lib/mongoid/extensions/time.rb' - - 'lib/mongoid/timestamps/updated.rb' - 'spec/integration/criteria/date_field_spec.rb' - 'spec/integration/criteria/raw_value_spec.rb' - 'spec/integration/persistence/range_field_spec.rb' @@ -834,7 +907,15 @@ Rails/TimeZone: - 'spec/mongoid/touchable_spec.rb' - 'spec/support/models/post.rb' -# Offense count: 4 +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: exists, where +Rails/WhereExists: + Exclude: + - 'lib/mongoid/association/referenced/has_many/enumerable.rb' + +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. # RedundantRestArgumentNames: args, arguments @@ -842,7 +923,6 @@ Rails/TimeZone: # RedundantBlockArgumentNames: blk, block, proc Style/ArgumentsForwarding: Exclude: - - 'lib/mongoid/association/referenced/has_many/enumerable.rb' - 'lib/mongoid/association/referenced/has_many/proxy.rb' # Offense count: 5 diff --git a/gemfiles/standard.rb b/gemfiles/standard.rb index 4f364e734..52b45aef8 100644 --- a/gemfiles/standard.rb +++ b/gemfiles/standard.rb @@ -9,10 +9,10 @@ def standard_dependencies group :development, :test do gem 'rubocop', '~> 1.63.4' - gem 'rubocop-performance', '~> 1.16.0' - gem 'rubocop-rails', '~> 2.17.4' + gem 'rubocop-performance', '~> 1.21.0' + gem 'rubocop-rails', '~> 2.24.1' gem 'rubocop-rake', '~> 0.6.0' - gem 'rubocop-rspec', '~> 2.19.0' + gem 'rubocop-rspec', '~> 2.29.2' end group :test do