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
770 stars 226 forks source link

Break down VB S3385 rule for Exit based on block type #2138

Open duncanp-sonar opened 5 years ago

duncanp-sonar commented 5 years ago

[Moved from https://github.com/SonarSource/sonarlint-visualstudio/issues/766, created by @burtonrodman]

In VB.Net, the SonarLint rule S3385 Remove this 'Exit' statement triggers on all types of Exit statements.

Please break this down into multiple rules so that severities can be assigned for each case:

There are some that have no replacement (like Exit Do, Exit While) -- these should be suggestions to restructure the code -- or ignored.

I think that Exit (i.e. kill process) should be banned entirely, so deserves a separate rule that can be marked as Error.

Exit Sub can blindly be replaced with Return, while Exit Function must be manually analyzed to ensure that it doesn't affect flow control/return value.

So as you can see each Exit variant deserves it's own rule so that severity can be managed appropriately for each.

Also, please improve the Description to provide more actionable guidance.

Corniel commented 5 years ago

I agree. This rule is a good start, but it needs improvement as described by @duncanp-sonar .