When to use `silent` code analysis severity?
Asked Answered
U

3

23

Analyzer feedback severity levels are explained in the documentation. But in my eyes silent and none severity levels seem both to have the same meaning - "I don't want this rule checked for":

For none:

Suppressed completely.

For silent:

Non-visible to user. The diagnostic is reported to the IDE diagnostic engine, however.

What exactly is the effect of "reporting to IDE" for VS2019 and in what scenarios should one prefer silent over none?

Upgrade answered 18/11, 2019 at 12:36 Comment(2)
was just wondering the same myself; I see no replies but did you find any information outside of stackoverflow?Parmesan
@ChristopherKing Nothing. wrote my take as answer.Katonah
O
15

I think silent shows up in the editor as the "three dots" or ghosted text, while none doesn't show up. I might recall this not behaving consistently in the past, but it seems to happen in Visual Studio 16.10.0. I like Imre's suggestions.

enter image description here

It seems like:

  • suggestion, error, and warning show up in the editor and Error List.
  • silent shows up only in the editor.
  • none shows up in neither.
Oskar answered 2/6, 2021 at 0:17 Comment(10)
Interesting.. that is, contrary to the quoted definition in OP, "silent" is visible to the user;)´´. Go figure.Katonah
Exactly. I think they meant "non-visible in the Error List". It seems that suggestion/error/warning show up in the editor and Error List; silent shows up only in the editor; and none shows up nowhere. The error list is sometimes out of date, so I'm not totally sure.Oskar
I don't get the three dots in silent :(Ipa
This actually makes sense for silent: "The diagnostic is reported to the IDE diagnostic engine", meaning that you see the ... in the IDE, but not in the Error List. It's just not obvious at first what IDE diagnostic engine means.Ottinger
See 'Hidden' severity versus 'None' severity, which corresponds to silent vs none.Ottinger
@Ipa I also don't get the "3 dots" in silent. It's a bit of a shame, actually. I do have certain things I consider so unimportant I don't want them cluttering up the Information message list, but I wouldn't mind the 3 dots staying!Elysha
With your description, then what's the difference between silent and suggestion? I've never seen suggestions showing up in the errors list.Jaquiss
@Jaquiss Looks like my suggestions are green squiggles, and are in Error List. Are the Error/Warning/Message toggle buttons enabled in your Error List?Oskar
@Oskar I don't have such a project at hand now. Green squiggles have always been warnings for me, suggestions had the three grey dots.Jaquiss
@yogue When I filter on suggestion, it affects the green squiggles and not the dots.Oskar
F
8

The distinction is explained in the documentation:

Hidden (silent) severity rules that are enabled by default differ from disabled or None severity rules in certain aspects.

  • If any code fix is registered for a Hidden severity rule, Visual Studio offers the fix as a light bulb code-refactoring action even if the hidden diagnostic isn't visible to the user. The fix isn't offered if the severity rule is disabled as None.
  • Hidden severity rules can be bulk configured by entries that set rule severity of multiple analyzer rules at once in an EditorConfig file. None severity rules can’t be configured this way. Instead, they must be configured through entries that set rule severity in an EditorConfig file for each rule ID.
Fled answered 17/11, 2022 at 9:55 Comment(1)
Sounds more plausible than the accepted answer.Jaquiss
U
5

Due to lack of better information and until proven wrong, I'm considering them equal for practical effect.

Still, considering this as an opportunity to define a useful semantic difference, I would suggest to:

  • USE none when you object to given rule in chosen scope. This rule is not mandatory to be followed.
  • USE silent for rules which must be followed, but are causing too much noise and are suppressed temporarily while still communicating the desired target state.
Upgrade answered 2/1, 2020 at 8:2 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.