Closed FStolte closed 2 years ago
I am having the exact same problem with the same setup mentioned above, looking forward to being solved. Thank you very much
This issue was reported also on our community: https://community.sonarsource.com/t/s1172-false-positives-in-visual-studio/60144.
It would be great if someone could look into this. It's pretty annoying. We have set WarningsAsErrors to true and especially when this S1172 triggers a lot of false positives, it is hard to find an actual error.
Any updates on this? This is still happening on SonarAnalyzer.CSharp 8.37.0.45539.
I'm currently working around the issue using the following line in my .editorconfig files:
dotnet_diagnostic.S1172.severity = none
Would much appreciate a proper fix. 🙂
I'm facing the same problem.
I can confirm this issue. It is not reproducible in a small test, but in bigger solutions is occurs quite often, but is a bit flaky.
Also experiencing this on most solutions. Issue is temporarily gone for a single file if the file is changed.
Appeared today in my solutions (at least two)
Extension updated today to 6.1.0.45943
We are experiencing it at my company as well. It appears that neither solution size nor project type is a contributing factor (we build just about everything an enterprise operations division would, excluding mobile applications).
Disabling the rule is less than ideal: We need to know when parameters should be removed (we're cleaning up legacy code), but can't trust the linter to tell us the truth.
Hi, we're investigating the issue.
As reported by @tonto7973 in #5553
S1172 unused parameter reported in VS 2022 when the parameter is used. This is coming from Visual Studio IntelliSense only. Running a build does not produce these errors.
Sample code
/*
Warning S1172 Remove this parameter 'value', whose value is ignored in the method.
Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
*/
private static dynamic ToDynamic(object value)
{
var json = JsonConvert.SerializeObject(value); // <-- parameter 'value' used here
return JsonConvert.DeserializeObject(json, typeof(ExpandoObject));
}
We've identified the root cause of the problem, fix will follow
@pavel-mikula-sonarsource Glad to see a fix is forthcoming. Do you have an estimated date for releasing an update?
We expect to release analyzers next week. That will fix scenarios when our NuGet is consumed. I can't tell when the next SonarLint version will be released.
We expect to release analyzers next week. That will fix scenarios when our NuGet is consumed.
Great!
I can't tell when the next SonarLint version will be released.
Please prioritize it, when possible. Having hundreds of false-positives all over my code and I always have to filter them out.
Thx!
.NET Analyzers were just released. You can now follow this ticket on SonarLint side: https://github.com/SonarSource/sonarlint-visualstudio/issues/2989
Description
S1172 sometimes flags parameters of private methods, regardless of whether they are used or not.
Repro steps
Create a new project with one class
Add
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
to the project and trigger the code analysis. If the warning does not appear, try removing the AnalysisMode and triggering the analysis again.Expected behavior
No warning for rule S1172
Actual behavior
Sometimes the parameter
param
is flagged with S1172 despite being used in the method. This behavior is flaky, i.e. when editing the code, sometimes the warnings disappear again even if the code is the same.Related information