Skip to content
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

Fix S2342 FP: Flaky reports #9683

Open
bart-vmware opened this issue Oct 10, 2024 · 2 comments
Open

Fix S2342 FP: Flaky reports #9683

bart-vmware opened this issue Oct 10, 2024 · 2 comments
Assignees
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.

Comments

@bart-vmware
Copy link

Description

During ci-build, we randomly get build errors such as the following:

error S2342: Rename this enumeration to match the regular expression: '^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$'

The affected [Flags] enum is named FastTestConfigurations, which complies with the rule. Because we sometimes get this error, but not always, I suspect a static regex is being used that isn't thread-safe.

[Flags]
public enum FastTestConfigurations
{
    ConfigServer = 1,
    Discovery = 2,
    Connectors = 4,
    WaveFrontExport = 8,
    All = ConfigServer | Discovery | Connectors | WaveFrontExport
}

Repro steps

Not available, it happens randomly, but not always. I've seen this multiple times in Azure DevOps, running on Ubuntu against .NET 8. I haven't experienced it locally on Windows 11.

Known workarounds

Restart the cibuild, which usually makes the error go away.

Related information

  • C#/VB.NET Plugins version: 9.25.1.91650
  • Visual Studio version: 17.11.5
  • MSBuild / dotnet version: .NET 8
  • SonarScanner for .NET version (if used): N/A
  • Operating System: Ubuntu
@gregory-paidis-sonarsource gregory-paidis-sonarsource added Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be. labels Oct 11, 2024
@gregory-paidis-sonarsource gregory-paidis-sonarsource changed the title Flaky reports from S2342 Fix S2342 FP: Flaky reports Oct 11, 2024
@gregory-paidis-sonarsource
Copy link
Contributor

Hey there,
This is an interesting problem.
Since it is flaky, I am not sure how to investigate it.

Can you clarify what you mean by this?

Because we sometimes get this error, but not always, I suspect a static regex is being used that isn't thread-safe

@bart-vmware
Copy link
Author

Yeah, these things are usually hard to diagnose. I was just guessing, without looking at the source code. It may as well be a race condition somewhere in Sonar code or the underlying compiler.

The project where this happens is open-source under the .NET Foundation. Sources are at https://github.com/SteeltoeOSS/Steeltoe. I've tried to dig up a build log, but couldn't find it back in the large amount of builds. I'll post it here when it happens again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

2 participants