Hi,
I would like to add an exception to the rule S2360 - Optional parameters should not be used for API Controller. In this case, it is allowed to use optional parameters to define default value for query parameter. So, API controller should be excluded from this rules.
- What language is this for? c#, dotnet
- Which rule? S2360
- Why do you believe it’s a false-positive/false-negative?
- It is a false positive for API controller usage. To define optional query parameter in .net, we have to use optional parameter, like in this example: Create web APIs with ASP.NET Core | Microsoft Learn.
- Are you using
- SonarQube Server : v10.6
- How can we reproduce the problem? Use optional parameter in an API controller and the rule detects the issue.
Regards