Open urmel9 opened 11 months ago
Hello @urmel9,
Thank you for reaching out!
I tried to reproduce the issue based on your description, this is what I found/understood:
Considering this code where S1172 is raised:
DoSomething(21, 42);
void DoSomething(int a, int b) // S1172 - b is unsed
{
Console.WriteLine(a);
}
As of today, when applying the code fix this is the result:
DoSomething(21, 42);
// ^^^^ <- This is expected to be removed as well.
void DoSomething(int a)
{
Console.WriteLine(a);
}
You are expecting the DoSomething(21, 42);
call to become DoSomething(21);
but is not updated, is that correct?
Yea, exactly @sebastien-marichal ! :) Because otherwise the compiler throws an error because the function DoSomething is not overload (and expect 1 param). So you have to delete it by yourself
Nevertheless, this is a rule where we would turn off the autofix-feature because sometimes we just comment out certain variables :D But I raised another issue for that in the sonar community: https://community.sonarsource.com/t/new-feature-disable-autofix-for-specific-rules-in-editorconfig/102315/6
Thank you @urmel9 for the quick response!
I will add this issue to our backlog.
To fix the issue, SymbolFinder.FindCallersAsync could be used.
Problem:
The Autofix of S1172 leads to a follw-up error. The rule and the description are correct, but the autofix function is wrong. It deletes the param in the private function but ignores the function calls and leads to an IDE error.
Solution:
Delete unused param also in function call OR disable autofix for this rule.
Can you please fix this? Thank you :)
PS: Sadly, I could not reproduce the issue with the test code of the rule but literally two people in our team saw this problem :D