Modify rule S6964: Add more entries to the exceptions (#3948)

This commit is contained in:
Mary Georgiou 2024-05-30 14:41:43 +02:00 committed by GitHub
parent 5210f2cd7a
commit dfe6de9121
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,10 +20,19 @@ public class ProductsController : Controller
=== Exceptions
This rule does not raise an issue when:
This rule does not raise an issue when properties are decorated with the following attributes:
* properties are decorated with the https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.validation.validateneverattribute[ValidateNever] attribute.
* properties are in model classes which are not in the same project as the Controller class that references them. This is due to a limitation of Roslyn (see https://github.com/SonarSource/sonar-dotnet/issues/9243[here]).
* https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.validation.validateneverattribute[ValidateNever]
* https://www.newtonsoft.com/json/help/html/JsonPropertyRequired.htm[JsonProperty(Required = Required.Always)]
* https://www.newtonsoft.com/json/help/html/JsonPropertyRequired.htm[JsonProperty(Required = Required.AllowNull)]
* https://www.newtonsoft.com/json/help/html/PropertyJsonIgnore.htm[Newtonsoft.Json.JsonIgnore]
* https://www.newtonsoft.com/json/help/html/t_newtonsoft_json_jsonrequiredattribute.htm[Newtonsoft.Json.JsonRequired]
* https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonrequiredattribute[System.Text.Json.Serialization.JsonRequired]
* https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonignoreattribute[System.Text.Json.Serialization.JsonIgnore]
* https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.rangeattribute[Range]
* https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.bindneverattribute[BindNever]
Additionally, this rule does not raise for properties in model classes that are not in the same project as the Controller class that references them. This is due to a limitation of Roslyn (see https://github.com/SonarSource/sonar-dotnet/issues/9243[here]).
== How to fix it