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 S6964 FP: Should not raise for reference properties in nullable context #9308

Merged
merged 4 commits into from
May 22, 2024

Conversation

mary-georgiou-sonarsource
Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource commented May 21, 2024

Fixes #9284

Copy link
Contributor

@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource left a comment

Choose a reason for hiding this comment

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

Good, but changes are needed to handle all non-nullable reference types, not just strings.

@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title Fix S6964 FP: Should not raise for string properties Fix S6964 FP: Should not raise for reference properties in nullable context May 22, 2024
@@ -23,24 +28,3 @@ public IActionResult Create(ModelUsedInController model)
}
}
}

namespace CustomGenerics
Copy link
Contributor

Choose a reason for hiding this comment

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

Why were these test cases removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrong push! I'll revert.

@@ -7,11 +7,16 @@ namespace NullableReferences
public class ModelUsedInController
{
#nullable enable
public string NonNullableReferenceProperty { get; set; } // Noncompliant
public string NonNullableReferenceProperty { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public string NonNullableReferenceProperty { get; set; }
public string NonNullableReferenceProperty { get; set; } // Compliant - ASP.NET Core treats non-nullable reference types as if they were decorated with the [Required] attribute

Copy link
Contributor

@zsolt-kolbay-sonarsource zsolt-kolbay-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. Please check the last two comments I've added.

Copy link

sonarcloud bot commented May 22, 2024

Quality Gate Passed Quality Gate passed for 'Sonar .NET Java Plugin'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented May 22, 2024

Quality Gate Passed Quality Gate passed for 'SonarAnalyzer for .NET'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit 91826ed into master May 22, 2024
26 checks passed
@mary-georgiou-sonarsource mary-georgiou-sonarsource deleted the mary/S6964-FP-strings branch May 22, 2024 12:50
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 S6964 FP: Should not raise for reference properties in nullable context
2 participants