File scoped namespace in c# 10 was reported as a bug

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:

namespace SomeSpace;

public class Foo
{
}

  • steps to reproduce
  1. Create a class
  2. Write code above
  3. Scan by SonarQube
  4. Then the error is shown
  • potential workaround

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

Hi,

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).

 
HTH,
Ann

Hi Ann,

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?

Thanks again.
Best regards
Lee

Hi,

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.

 
HTH,
Ann

Hi Ann,

Thanks for your answer.

We will temporarily remove this rule in our Sonar config :slight_smile: :grinning:

Thanks very much.
Best regards

Lee