-
-
Notifications
You must be signed in to change notification settings - Fork 356
There are too many ways to toggle diagnostics #1364
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
Comments
|
Is there a reason why I wouldn't consider If |
For me, all the two settings can be accepted. I did not modify it just to keep compatible. |
I understand that you want to keep it backwards compatible, but I think having three settings to enable/disable diagnostics ( For example, I have used this extension in VS Code for over a year at this point and I had no idea that the I think it is needlessly complex and is very confusing to new users. Having one setting called |
I think I can remove |
I still think the groups add extra complexity for both developers and users.
This added complexity only serves to make configuring a little faster, assuming that changing an entire group of settings is actually what you want to do. Personally, I would never use the groups setting and only enable/disable the diagnostic I actually want to change, but maybe we get some more opinions? |
@Nexela @FlashHit @Rouneq @sewbacca @flrgh @lua-rocks Sorry for the mass mention if you are not interested, but I noticed you guys are pretty active on this repository and I think your opinions would be very valuable here as this is a pretty substantial change. Please take a read through to get an understanding of the issue and then, if you could, provide your opinion on the situation. I just want to make sure I am not suggesting a major change that does not resonate with a lot of the community. Thank you 🙂. |
If I understand both sides of the discussion correctly, my main question would be: Is there a benefit to having so many different means of accomplishing the same task? For example, what's the driving use case for As for
or
|
@Rouneq I believe that
My point is that EDIT: I think of it like a linter config like ESLint, yes there are a lot of rules, but it lets you dial things in exactly how you want it. |
Right. |
My main concern with the groups is that you now have the toggling of diagnostics spread out across two settings. The group can also be specified as a I haven't even gotten into the fact that |
I think the groups can still be made to work, if there is a need for it, however, I don't see much of a need for it in the first place. It would also make sharing configs a bit harder as you would be sharing two settings instead of just one object. I think it could work like this:
"Lua.diagnostics.groupFileStatus": {
"global": "None"
}
"Lua.diagnostics.neededFileStatus": {
"lowercase-global": "Any"
}
|
I also think this is the best way. With the removal of the |
I don't have a very strong opinion about this myself, so please don't take any of this as much more than a couple naive ideas. Here are my thoughts around making the config more expressive and succinct by combining diagnostic groups with diagnostic names/identifiers, as well as allowing simple operator syntax like globbing and numeric. Note: I'm staying away from commenting on config names like diagnostics = {
-- groups and individual diagnostics both go in the same table using some
-- notation to separate them (probably "." or ":")
-- disabling a diagnostic using the fully-qualified (includes the group name) identifier
["type-check:need-check-nil"] = "None",
-- although groups _look like_ namespaces, they're just tags/labels, so diagnostic names
-- must be globally unique such that this is equivalent to the previous line
["need-check-nil"] = "None",
-- disabling all checks in a group by using globbing syntax
["ambiguity:*"] = "None",
-- setting an entire group's semantics using globbing syntax
["luadoc:*"] = "Opened",
-- disabling an entire group except for one specific diagnostic
--
-- requires some sort of formalized resolution order to work properly
-- (i.e. "Any" is resolved _after_ "None")
["duplicate:*"] = "None",
["duplicate:duplicate-set-field"] = "Any",
} Resolution order can be a problem with expressing intent succinctly, and I don't have a good solution for that. Older applications often allow the user to specify the resolution order (i.e. Apache's mod_access "Order" option), which is very useful, but that does introduce another configuration field (though maybe it's worth it if this more expressive format could eliminate several other config fields). Assigning and exposing diagnostic codes to diagnostics (this might even be the case already in the code--I haven't looked at it) would open up the door for more expressive syntax using ranges or numeric filters. The luacheck warnings are laid out like this. The first digit of the error code is a group/class of error, which feels intuitive to me, similar to HTTP codes (HTTP 4xx are client errors, HTTP 5xx are server errors). diagnostics = {
-- disable all 0xx, 1xx, and 2xx diagnostics
["<300"] = "None",
-- alternatively, using range notation
["0..299"] = "None",
-- disable diagnostic with code 412
["412"] = "None",
-- disable all 5xx diagnostics except 554
["500..599"] = "None",
["554"] = "Any",
} I think it would be good to look at |
I do like that glob pattern idea, that way we can keep the groups but only need one setting - best of both worlds! That is the kind of solution I was looking for 😁. As for resolution order, I think something like this could do: local config = {
["type-check:*"] = "None",
["need-check-nil"] = "Opened",
["duplicate:duplicate-set-field"] = "Any",
["duplicate:*"] = "None",
}
local keys = {}
for k, v in pairs(config) do
table.insert(keys, k)
end
table.sort(keys, function(a, b)
return (string.find(a, "*")) and not (string.find(b, "*"))
end)
-- keys are now sorted so all glob patterns are at the front
-- {type-check:*, duplicate:*, duplicate:duplicate-set-field, need-check-nil} This way all glob patterns are applied first and and then more specific settings are applied afterwards. We start broad and narrow in, allowing people to override group settings for an individual diagnostic. Not really a fan of the numerical codes though, it goes from a system where the diagnostic "IDs" go from pretty intuitive names like |
I do like the idea suggested by flrgh As well as sorting idea by carsakiller
|
As an amendment to my earlier comment, I think the groups concept could be made irrelevant if diagnostic/error names were consistently named with a prefix. I.E. instead of this: {
duplicate = {
"global-in-nil-env",
"lowercase-global",
-- ...
},
global = {
"circle-doc-class",
"doc-field-no-class",
-- ...
},
} ...this: {
"duplicate-global-in-nil-env",
-- alternatively, with `:` as a separator instead of `-`
"duplicate:lowercase-global",
-- ...
"global-circle-doc-class",
"global-doc-field-no-class",
-- ...
} This still jives with being able to use glob syntax to enable/disable one or many diagnostics easily, and I think it's more intuitive than having to look up which "group" a diagnostic belongs to. The config parser need not to be aware of the group concept either. It's just handling strings and glob patterns, so Also, no added confusion about |
Why is there 3 different ways to disable diagnostics?
The Problem
Currently, there is:
Lua.diagnostics.disable
Lua.diagnostics.neededFileStatus
key
is the name of the diagnostic and thevalue
is how the diagnostic will be checked (not at all, only open files, all files)Lua.diagnostics.groupFileStatus
key
is the name of the group and thevalue
is how the group of diagnostics will be checked (not at all, only open files, all files)This can get very confusing very quickly.
The solution
I think going with just
Lua.diagnostics.neededFileStatus
would make the most sense.It allows for the user to completely customize how the server runs, which is more important than the user quickly being able to get things working sort of how they like it in the short-term.
To still help get users up and running as fast as possible, we can offer "presets" or "popular configs" on the discussions page. This can help satisfy those that want just the basics or full strict mode.
This would definitely be a breaking change but I think it is a very important one to make!
Originally posted by @carsakiller in #1362 (comment)
The text was updated successfully, but these errors were encountered: