You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RuboCop will warn me when let() helper has been defined twice inside my rspec examples
Actual behavior
The following piece of RSpec code will produce a segmentation fault. See Ruby #10460.
# frozen_string_literal: true
describe 'my attempt' do
let(:user) { 'user 1' }
let!(:client) { 'Client ' + user }
let(:user) { client.lower }
it 'some tests' do
p user
end
end
However RuboCop doesn't detect that as an offence. In practice the problem was hidden under layers of shared examples and became obvious after I expanded the code to see what it does. Sounds like an easy thing to do for RuboCop, doesn't it ?
Inspecting 1 file
C
Offenses:
spec/segfault_spec.rb:2:10: C: RSpec/DescribeClass: The first argument to describe should be the class or module being tested.
describe 'my attempt' do
^^^^^^^^^^^^
1 file inspected, 1 offense detected
@backus I guess this falls under rubocop-rspec, let me know if you want me to open the RFE under the other repo ?
@atodorov this would be more appropriate for rubocop-rspec but I would probably still say that it isn't a great task for static analysis. I have a project (backus/rspec-lint) which I think is better suited for this sort of detection. All it currently does it detect unused let definitions but that is still flakey. It isn't ready for prime time yet but I'd recommend opening the issue there.
Expected behavior
RuboCop will warn me when let() helper has been defined twice inside my rspec examples
Actual behavior
The following piece of RSpec code will produce a segmentation fault. See
Ruby #10460.
However RuboCop doesn't detect that as an offence. In practice the problem was hidden under layers of shared examples and became obvious after I expanded the code to see what it does. Sounds like an easy thing to do for RuboCop, doesn't it ?
Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: