#15733·rubocop

Bug Report: --only option ignores FactoryBot/AttributeDefinedStatically

Author: ydakukaCreated May 16, 2023Updated Sep 20, 2026

Actual behavior

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop spec/factories/masks.rb
Inspecting 1 file
C

Offenses:

spec/factories/masks.rb:6:5: C: [Correctable] FactoryBot/AssociationStyle: Use implicit style to define associations.
    association :blocklist, strategy: :build
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/factories/masks.rb:6:5: C: [Correctable] FactoryBot/AttributeDefinedStatically: Use a block to declare attribute values.
    association :blocklist, strategy: :build
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 2 offenses detected, 2 offenses autocorrectable
ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop spec/factories/masks.rb --only FactoryBot/AssociationStyle
Inspecting 1 file
C

Offenses:

spec/factories/masks.rb:6:5: C: [Correctable] FactoryBot/AssociationStyle: Use implicit style to define associations.
    association :blocklist, strategy: :build
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense autocorrectable
ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop spec/factories/masks.rb --only FactoryBot/AttributeDefinedStatically
Inspecting 1 file
.

1 file inspected, no offenses detected

RuboCop version

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop -V
1.50.2 (using Parser 3.2.2.1, rubocop-ast 1.28.1, running on ruby 2.7.8) [x86_64-linux]
  - rubocop-capybara 2.18.0
  - rubocop-performance 1.17.1
  - rubocop-rails 2.19.1
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.22.0

FactoryBot version

factory_bot (6.2.1)
  activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
  factory_bot (~> 6.2.0)
  railties (>= 5.0.0)