Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive Rails/HttpStatus #443

Closed
tagliala opened this issue Sep 10, 2023 · 2 comments
Closed

False positive Rails/HttpStatus #443

tagliala opened this issue Sep 10, 2023 · 2 comments

Comments

@tagliala
Copy link
Contributor

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

@MaxLap
Copy link
Contributor

MaxLap commented Sep 11, 2023

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.

@sds
Copy link
Owner

sds commented Jun 24, 2024

Closing since a workaround has been provided. Thanks!

@sds sds closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants