Template for a good bug report, formatted with Markdown:
- versions used (SonarQube, Scanner, Plugin, and any relevant extension)
Developer Edition Version 8.9.5 (build 50698)
- error observed (wrap logs/code around triple quote ``` for proper formatting)
In c# 10, there was a change, the namespace can be written as below (Which is called file scope namespace), but if we scan the code, the SonarQube will report a bug: Move ‘XXX’ into a named namespace.
The change which is described by Microsoft is: File scoped namespaces - C# 10.0 draft specifications | Microsoft Docs
The code is:
public class Foo
- Create a class
- Write code above
- Scan by SonarQube
- Then the error is shown
P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour
Welcome to the community!
I’ve moved your post to the False-positive / False-negative category.
Thanks for including your version of SonarQube. Unfortunately, the LTS doesn’t include any support for C#10. We only started working on that in SonarQube 9.2.
Since the latest language features are important to you, you’ll want to upgrade to the latest version (currently 9.3) and stay up to date as new versions are released (9.4 expected 4 April).
Thank you so much!
Because only LTS version is allowed in our company, could you please tell me when will the next LTS version be published, and will it contain the newest c# 10 features?
On the other hand, could you please tell me how to resolve (ignore) this problem without upgrading our SonarQube version?
I believe we can expect the next LTS in 2023Q1. I do expect it to have C# 10 support, although I can’t currently predict how complete it will be.
In the meantime, I would just mark this issue a False Positive.
Thanks for your answer.
We will temporarily remove this rule in our Sonar config
Thanks very much.