haml-lint
haml-lint copied to clipboard
False positive Rails/HttpStatus
= render 'partial', status: 'future'
Expected
No lints detected
Actual
test.haml:1 [W] RuboCop: Rails/HttpStatus: Prefer `nil` over `future` to define HTTP status code.
1 file inspected, 1 lint detected
Versions
$ haml-lint -v
haml-lint 0.50.0
$ rubocop -V
1.56.2 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.0.4) [x86_64-darwin22]
- rubocop-capybara 2.18.0
- rubocop-factory_bot 2.23.1
- rubocop-performance 1.19.0
- rubocop-rails 2.21.0
- rubocop-rspec 2.24.0
I think this is an issue caused by Rails/HttpStatus which thinks it is running in a controller context.
Thanks for the report!
I'll be honest, I'm not sure how this should be handled. The Rails/HttpStatus is clearly not meant to be run on views. But I don't see how haml-lint can stop it from running...
The easiest way to solve your problem would be to add this to your regular .rubocop.yml config:
Rails/HttpStatus:
Exclude:
- '**/*.haml'
Sadly, I can't make this default in haml-lint since I don't know how I could detect that we are running with rubocop-rails.
Closing since a workaround has been provided. Thanks!