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 S3963 FP: Static constructor with conditional and no static filed initialization #9512

Merged
merged 3 commits into from
Jul 11, 2024

Conversation

sebastien-marichal
Copy link
Contributor

Fixes #6343

Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - mino polishing - ignore if you wish as it does not worth blocking the whole PR for this.

@@ -54,7 +54,7 @@ public sealed class InitializeStaticFieldsInline : SonarDiagnosticAnalyzer
.Distinct()
.Count();
var hasIfOrSwitch = Array.Exists(bodyDescendantNodes, x => x.IsAnyKind(SyntaxKind.IfStatement, SyntaxKind.SwitchStatement));
if ((hasIfOrSwitch && assignedFieldCount <= 1)
if ((hasIfOrSwitch && assignedFieldCount == 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one line :)

@sebastien-marichal sebastien-marichal enabled auto-merge (squash) July 11, 2024 11:53
Copy link

sonarcloud bot commented Jul 11, 2024

Copy link

sonarcloud bot commented Jul 11, 2024

@sebastien-marichal sebastien-marichal merged commit bc2307e into master Jul 11, 2024
26 checks passed
@sebastien-marichal sebastien-marichal deleted the sma/s3963-fp branch July 11, 2024 12:18
@sebastien-marichal
Copy link
Contributor Author

Peach validation:

  • 39 Lost issues => All TNs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix S3963 FP: Static constructor with conditional and no static filed initialization
2 participants