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: Don't raise on properties annotated with the JsonRequiredAttribute #9275

Closed
Hoffs opened this issue May 14, 2024 · 1 comment · Fixed by #9304
Closed

Fix S6964 FP: Don't raise on properties annotated with the JsonRequiredAttribute #9275

Hoffs opened this issue May 14, 2024 · 1 comment · Fixed by #9304
Assignees
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Projects
Milestone

Comments

@Hoffs
Copy link

Hoffs commented May 14, 2024

Description

S6964 complains about "under-posting" when fields are not nullable, even though JsonRequired is specifically intended to avoid this issue.

Repro steps

public record MyRequestDto([property: JsonRequired] decimal Amount)

Expected behavior

No issue reported.

Actual behavior

S6964 issue reported.

Known workarounds

Please provide a description of any known workarounds.

Related information

  • C#/VB.NET Plugins version SonarScanner 5.0.1.3006
  • Visual Studio version N/A
  • MSBuild / dotnet version - MSBuild 6.2, dotnet 8
  • SonarScanner for .NET version (if used) dotnet-sonarscanner/6.2.0
  • Operating System Linux 5.10.184-175.731.amzn2.x86_64 amd64
@CristianAmbrosini CristianAmbrosini changed the title Fix S6964 FP/FN: JsonRequired is not taken into account Fix S6964 FP: JsonRequired is not taken into account May 15, 2024
@mary-georgiou-sonarsource
Copy link
Contributor

Hello, @Hoffs!
I confirm this is a false positive and I'll add it to our backlog.

Thanks for reporting it.

@mary-georgiou-sonarsource mary-georgiou-sonarsource added Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be. labels May 15, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title Fix S6964 FP: JsonRequired is not taken into account Fix S6964 FP: Don't raise on properties annotated with JsonRequired May 15, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title Fix S6964 FP: Don't raise on properties annotated with JsonRequired Fix S6964 FP: Don't raise on properties annotated with the JsonRequiredAttribute May 15, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource added this to the 9.26 milestone May 21, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource added the Sprint: Hardening Fix FPs/FNs/improvements label May 21, 2024
@github-actions github-actions bot moved this from To do to Review in progress in Best Kanban May 21, 2024
Best Kanban automation moved this from Review in progress to Validate Peach May 21, 2024
@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource moved this from Validate Peach to Done in Best Kanban May 22, 2024
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. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Projects
Best Kanban
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants