SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
796 stars 228 forks source link

Fix S1172: code fix does not delete unused parameter in function call #9534

Closed sebastien-marichal closed 1 month ago

sebastien-marichal commented 4 months ago

Fixes #8187

It does not support changing usage outside of the current SyntaxTree (e.g.: in case of usage in partial class).

sebastien-marichal commented 4 months ago

Low coverage is due to defensive coding. I'm not sure I can improve; @tim-pohlmann, if you have any ideas, I'm all ears.

denis-troller commented 4 months ago

Can we make sure we find a way to deal with cases where the argument to remove has a side effect?

//...
MyFunction(a, i++);
//... use I later
//...

public void MyFunction(int a, int b)
{
// ... only use a
}
sebastien-marichal commented 4 months ago

As discussed, as arguments can include very complex expressions, I am only removing argument expressions that do no updates whatsoever.

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed for 'Sonar .NET Java Plugin'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarcloud[bot] commented 4 months ago

Quality Gate Failed Quality Gate failed for 'SonarAnalyzer for .NET'

Failed conditions
87.2% Coverage on New Code (required ≥ 95%)

See analysis details on SonarCloud