S125 C#: switch keyword recognized as commented code

  • What language is this for?
    C#

  • Which rule?
    S125

  • Why do you believe it’s a false-positive/false-negative?
    The switch keyword flags a comment as commented-out code.

  • Type and version used:
    SonarQube Server Enterprise Edition v2026.1 (119033)

  • How can we reproduce the problem?
    Comments containing switch trigger the Rule. For example:

// The application can switch between multiple modes at runtime.

This comment is reported as a violation of S125.

When switch is replaced with change, the violation is no longer reported:

// The application can change between multiple modes at runtime.

Hey @MartinMM, welcome to the Community!

We weren’t able to reproduce the issue. Just adding the comment you mentioned didn’t trigger the issue. Could you share a minimum reproducible project or file? Could you also share a screenshot of the issue being triggered?

An extra note: 2026.1 LTA, although still a supported version, is not the latest, and there is a possibility that this has been fixed on a later version. I haven’t seen any significant changes made in this rule recently, though.

Thank you for responding! Because the original comment includes client data and I thought that the switch keyword would be the sole cause I did not double check (my mistake!). After looking at the original comment again I think I missed something crucial. What follows is a closer representation of the original comment:

// The application can switch (different placeholders) between multiple nodes at runtime.

I think the () play a crucial role.
Similarly to my post above the rule violation resolved after swapping switch with change

//The application can change (different placeholders) between multiple nodes at runtime.

I only substituted words but kept every special character, that was present in the flagged comment.

@MartinMM still no luck… does // The application can switch (different placeholders) between multiple nodes at runtime. trigger the issue for you? May I ask you to try creating a dummy file or function where you can paste your original code, trim it down to a point where it’s shareable but the issue still persists? Before sharing a snippet, I would please ask you that you verify yourself that it raises the issue (you can just create a dummy branch or PR in your project to not pollute it).

Thank you for replying! I have attached a simple dummy project, that resulted in the rule violation and a screenshot of the dashboard.
S125Repro.zip (555.3 KB)

@MartinMM thanks for sharing, yes, I can see it now, I’ll let the devs know

Thank you very much!

Hi @MartinMM, thanks for sharing the reproducer! We confirmed that this issue is fixed in C# analyzer 10.35.0.4138. Your attached example no longer raises S125 with that version.