I decided to add stricter linting to the codebase. Since I like what standard offers, I simply extended it with rails specific lints, in the following way:
require:
- standard
- rubocop-rails
- rubocop-rspec
- rubocop-performance
inherit_gem:
standard: config/ruby-3.0.yml
AllCops:
TargetRubyVersion: 3.1
NewCops: enable
Exclude:
- bin/**/*
- public/**/*
- vendor/**/*
- db/schema.rb
Rails:
Enabled: true
RSpec:
Enabled: true
RSpec/ExampleLength:
Enabled: false
RSpec/MultipleExpectations:
Max: 4
Performance:
Enabled: true
This ensures standard is used for ruby things, and rails, rspec and some other performance related checks in addition to it via rubocop.
I came across this suggestion while fixing the 100 odd offenses it threw up,
RSpec/NamedSubject:
Name your test subject if you need to reference it explicitly.
The fix,
subject(:run) { create(:releases_train_run) }
But what even is this? Isn't this just a let
really? You can't really use the is_expected.to
shortcut either since it's now named. I cannot possibly make the claim that this reads better.
I think it's just one of those annoying rspec maximalisms.