Skip to content

HLS HLint plugin doesn't preserve HLint's severities #3881

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

Closed
dariooddenino opened this issue Nov 27, 2023 · 3 comments
Closed

HLS HLint plugin doesn't preserve HLint's severities #3881

dariooddenino opened this issue Nov 27, 2023 · 3 comments
Labels
level: easy The issue is suited for beginners type: enhancement New feature or request

Comments

@dariooddenino
Copy link

Your environment

Which OS do you use?
Ubuntu 20.04
Which version of GHC do you use and how did you install it?
9.2.8 form ghcup

Which LSP client (editor/plugin) do you use?
helix
Which version of HLS do you use and how did you install it?
2.4.0.0 from ghcup
Have you configured HLS in any way (especially: a hie.yaml file)?
I have a hie.yaml file, but I don't think it's relevant to this issue.

What's wrong?

I have added this line to my .hlint.yaml file:

- error: {name: Avoid restricted module}

When running hlint I correctly get:

src/Domain/EntityEvent.hs:8:1-24: Error: Avoid restricted module
Found:
  import Infrastructure.DB
Note: may break the code

1 error

HLS reports the same issue but with severity: 3, making it render as a suggestion instead of an error in my editor:

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"Avoid restricted module","message":"Avoid restricted module\nFound:\n  import Infrastructure.DB ( foo )\nmay break the code\n","range":{"end":{"character":30,"line":7},"start":{"character":0,"line":7}},"severity":3,"source":"hlint"}],"uri":".../src/Domain/EntityEvent.hs","version":1}}

Is this something that's not supported (yet)? Is it possible that it's hlint's fault instead?

Thanks

@dariooddenino dariooddenino added status: needs triage type: support User support tickets, questions, help with setup etc. labels Nov 27, 2023
@michaelpj
Copy link
Collaborator

The hlint plugin sets the severity to Information always: https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs#L252

No comment, so who knows why. I think it would be pretty reasonable to follow hlint's severities there, should be an easy fix.

@michaelpj michaelpj added type: enhancement New feature or request and removed type: support User support tickets, questions, help with setup etc. status: needs triage labels Dec 12, 2023
@michaelpj michaelpj changed the title HLS reporting HLINT custom error hints with severity: 3 HLS HLint plugin doesn't preserve HLint's severities Dec 12, 2023
@michaelpj michaelpj added the level: easy The issue is suited for beginners label Dec 12, 2023
IAmPara0x added a commit to IAmPara0x/haskell-language-server that referenced this issue Dec 15, 2023
@IAmPara0x
Copy link
Contributor

IAmPara0x commented Dec 15, 2023

I have created a PR for it: #3902. And I have tested it locally. Hope this solves the issue.

mergify bot pushed a commit that referenced this issue Jan 22, 2024
…#3902)

* Fix issue:  HLS HLint plugin doesn't preserve HLint's severities #3881

preserve severity from HLint

* Fix tests

* Only preserve error serverity from hlint

* Add comment explaining the propogation of error level serverity

---------

Co-authored-by: Michael Peyton Jones <[email protected]>
josephsumabat pushed a commit to josephsumabat/haskell-language-server that referenced this issue Jan 22, 2024
…ll#3881 (haskell#3902)

* Fix issue:  HLS HLint plugin doesn't preserve HLint's severities haskell#3881

preserve severity from HLint

* Fix tests

* Only preserve error serverity from hlint

* Add comment explaining the propogation of error level serverity

---------

Co-authored-by: Michael Peyton Jones <[email protected]>
@michaelpj
Copy link
Collaborator

Just as a note for anyone coming here in future: we decided on the following behaviour:

  • error severities are kept
  • all other severities are downgraded

This is because hlint pervasively uses "warning" to mean something much less severe than GHC's warnings, but its "error"s are still pretty bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level: easy The issue is suited for beginners type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants