Skip to content

Add ability to disable specific diagnostics#2777

Merged
dantleech merged 2 commits intophpactor:masterfrom
bart-jaskulski:gh-2728
Nov 16, 2024
Merged

Add ability to disable specific diagnostics#2777
dantleech merged 2 commits intophpactor:masterfrom
bart-jaskulski:gh-2728

Conversation

@bart-jaskulski
Copy link
Copy Markdown
Contributor

Minimal POC for #2728. Currently doesn't work with WorseReflection diagnostics (e.g. missing return).

Minimal POC for phpactor#2728. Currently doesn't work with WorseReflection
diagnostics (e.g. missing return).

Signed-off-by: Bart Jaskulski <[email protected]>
@bart-jaskulski
Copy link
Copy Markdown
Contributor Author

With this, you can add to your phpactor config:

{
  "language_server.disabled_diagnostics": [
    "fix_namespace_class_name"
  ]
}

@bart-jaskulski
Copy link
Copy Markdown
Contributor Author

I don't know if there's a reliable way to discover existing diagnostics identifiers right now

Signed-off-by: Bart Jaskulski <[email protected]>
@dantleech dantleech merged commit 8c7da5c into phpactor:master Nov 16, 2024
dantleech added a commit that referenced this pull request Nov 16, 2024
@dantleech
Copy link
Copy Markdown
Collaborator

dantleech commented Nov 16, 2024

actually think I was rather hasty there.

this disables diagnostic providers not diagnostics, would revert in #2780 unless I can quickly fix it.

@bart-jaskulski
Copy link
Copy Markdown
Contributor Author

Well, I could marked it as draft, as I planned on adding tests and other providers to exclude (like mentioned, this did not work with WorseRef extension).

Tbh, there's no way to disable specific diagnostic, only it's provider. I assumed it was fine (it's how rules mechanism works e.g. in PhpCodeSniffer), but I can also refactor it to add identifiers for diagnostics and a way for filtering them.

Besides, for what I understand, currently there are two levels of diagnostics providers:

  1. Diagnostic group, like code-action
  2. Diagnostic provider, like namespace fix

And atm you can allow for specific groups to be enabled. As it is a broad scope, it would be nice too to use deny list for unwanted providers (or specific diagnostics).

Happy to further discuss it, as it may be my overengineering of related issue problem.

@dantleech
Copy link
Copy Markdown
Collaborator

I've had a "quick" (heh, hours) go at adding diagnostic codes to all diagnostics:

#2781

I think this is the way forward as it's a pretty generic solution... needs a little bit of reflection and change in the language-server package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants