Phil Pirozhkov
Phil Pirozhkov
Good catch, thanks for bringing this up. 👍 I guess the cop should be split into the one that suggests a better file name basing on the constant name, and...
False positives: 1. Factories ```ruby FactoryBot.define do factory :project do submitted_by { create(:user) } end ``` 2. Methods ```ruby describe Organisation, type: :model do def setup_contribution_data most_pr_user = create(:user) ```...
> > forbidden calls directly under example groups (and inside iterators directly under example groups) Small correction, iterators and conditionals. ```ruby RSpec.describe do if pre_create user = create(:user) end ......
> > forbidden calls directly under example groups (and inside iterators directly under example groups) > I'd have to allow things like: Not sure if the detecting the receiver would...
```ruby return if example_group?(node.ancestors(:block).first) ``` > I think you meant unless instead of if but essentially Exactly. > This seems to work but will have to get a long list...
I would probably call this cop `Rails/PersistenceCalledOutsideExample`. RuboCop soon introduces nested departments, so it will end up being an `RSpec/Rails/PersistenceCalledOutsideExample`.
Sorry, it's taking me longer than usual to review. Hope to get to it soon.
Another attempt to digest and classify `47880 files inspected, 6580 offenses detected` from `real-world-rspec`. 1. (no need to fix, but delays this PR up until `rubocop-rspec` 2.0-beta) Custom setup blocks...
Sorry, I've missed your comment about the recent changes you've made. > for example: klass.create! would look like a local variable but point to an AR instance. Agree. Also, on...
No false positives. But no real offences either :D With that much information on hand we can only theoretize. This cop is ~90 LoC. It's a maintenance cost. I have...