haml-lint icon indicating copy to clipboard operation
haml-lint copied to clipboard

False positive Rails/HttpStatus

Open tagliala opened this issue 2 years ago • 1 comments

= 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.

tagliala avatar Sep 10 '23 15:09 tagliala

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.

MaxLap avatar Sep 11 '23 21:09 MaxLap

Closing since a workaround has been provided. Thanks!

sds avatar Jun 24 '24 19:06 sds