-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FactoryBot/AttributeDefinedStatically doesn't work well #1044
Comments
Wondering why this https://github.com/rubocop-hq/rubocop-rspec/blob/e11f6e3c4a539203185e0e11089c8fe2e8f05393/config/default.yml#L8 doesn't work for you. |
Regarding the AllCops:
RSpec/FactoryBot:
Patterns:
- spec/factories/**/*.rb this was the first thing I tried, but my attempt failed - the same behavior as before 😞 . Here is an example of output with the bundle exec --gemfile gemfiles/rubocop.gemfile rubocop spec/dummy/config/initializers/seo.rb --debug
For /Users/chubchenko/applications/seo: configuration from /Users/chubchenko/applications/seo/.rubocop.yml
configuration from /Users/chubchenko/.rvm/gems/ruby-2.6.5/gems/rubocop-performance-1.8.1/config/default.yml
configuration from /Users/chubchenko/.rvm/gems/ruby-2.6.5/gems/rubocop-performance-1.8.1/config/default.yml
Default configuration from /Users/chubchenko/.rvm/gems/ruby-2.6.5/gems/rubocop-0.93.1/config/default.yml
configuration from /Users/chubchenko/.rvm/gems/ruby-2.6.5/gems/rubocop-rails-2.8.1/config/default.yml
configuration from /Users/chubchenko/.rvm/gems/ruby-2.6.5/gems/rubocop-rails-2.8.1/config/default.yml
configuration from /Users/chubchenko/.rvm/gems/ruby-2.6.5/gems/rubocop-rspec-1.43.2/config/default.yml
configuration from /Users/chubchenko/.rvm/gems/ruby-2.6.5/gems/rubocop-rspec-1.43.2/config/default.yml
Inspecting 1 file
Scanning /Users/chubchenko/applications/cms-seo/spec/dummy/config/initializers/seo.rb
Loading cache from /Users/chubchenko/.cache/rubocop_cache/6655e55d54761e1e00b5da5b9a104451067030e3/6d7a3b621ca1730e04accd938619e4bdab66cfb1/48dc38c32c72316fef6fe5bddb16f10a6b0fd8cc
C
Offenses:
spec/dummy/config/initializers/seo.rb:28:5: C: FactoryBot/AttributeDefinedStatically: Use a block to declare attribute values.
ignore.push(%r{\A/admin.*}.freeze)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/dummy/config/initializers/seo.rb:29:5: C: FactoryBot/AttributeDefinedStatically: Use a block to declare attribute values.
ignore.push(%r{\A/\z}.freeze)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 2 offenses detected, 2 offenses auto-correctable
Finished in 0.7074670000001788 seconds |
Do you mind sharing the |
@bquorning Do you think we need to make some changes to the |
Yes, no problem. Here is the configuration file: require:
- "rubocop-performance"
- "rubocop-rails"
- "rubocop-rspec"
AllCops:
Exclude:
- "bin/*"
- "spec/dummy/bin/*"
- "spec/dummy/db/**/*"
TargetRubyVersion: 2.5
NewCops: enable
############### Layout ###############
Layout/LineLength:
Max: 120
############### Naming ###############
Naming/PredicateName:
AllowedMethods:
- "is_a?"
- "have_redirect"
############### Style ###############
Style/Documentation:
Enabled: false
############### Metrics ###############
Metrics/AbcSize:
IgnoredMethods:
- "change"
- "redirectable"
Metrics/BlockLength:
ExcludedMethods:
- "register"
- "describe"
- "shared_examples"
Metrics/MethodLength:
ExcludedMethods:
- "change"
############### Rails ###############
Rails/SkipsModelValidations:
Exclude:
- "app/models/seo_module/redirect.rb"
- "app/services/seo_module/redirect/kill_cycling.rb"
- "lib/seo_module/admin/redirect.rb"
Rails/DynamicFindBy:
Whitelist:
- "find_by_page_type_and_slug"
############### RSpec ###############
RSpec/DescribeClass:
Exclude:
- "spec/system/**/*"
RSpec/ExampleLength:
Exclude:
- "spec/system/**/*"
Max: 10
RSpec/MultipleExpectations:
Exclude:
- "spec/system/**/*"
Max: 2 |
Actually, I started thinking maybe it’s time to move the FactoryBot code into a separate gem (e.g. RuboCop-FactoryBot). Do the three FactoryBot cops rely on any RSpec cop specific code (the |
I support the idea. Reasoning:
Cons:
Side note: we will still have to use über-departments since the whole problem was due to Concerning file locations, as per FactoryBot doc, we should be looking in:
Another wild idea would be to submit those cops directly to FactoryBot itself, but according to my recent experience, their maintainers are not too responsive. |
When processing the following code:
I have the next recommendation:
Also, I have the same recommendation in another file:
The text was updated successfully, but these errors were encountered: