JAM-Software / SonarDelphi

This repository contains the source code to the Sonar-Delphi plugin. Can be used to analyse Delphi projects with SonarQube.
31 stars 12 forks source link

EmptyBeginStatementRule should not match if method body contains a comment #1

Open joachimmarder opened 3 years ago

joachimmarder commented 3 years ago

Often an empty method body is justified by a comment. In this case the EmptyBeginStatementRule should not match.

Ajoschi commented 3 years ago

@joachimmarder : I think this makes sense for virtual or override methods. However, I'm not sure about none-virtual methods (don't see a reason/usecase for empty none-virtual method)

joachimmarder commented 3 years ago

However, I'm not sure about none-virtual methods

@Ajoschi: A method implementation can be required by an interface but in some cases there is no implementation that makes sense. Such methods can still be non-virtual.

In any case you could simply add an exit statement to get rid of the warning.

Ajoschi commented 3 years ago

...implementation can be required by an interface...

Right! Did not think about this use case. Thx @joachimmarder

joachimmarder commented 3 years ago

Same rule for C# also accepts comments as non-empty method body: https://rules.sonarsource.com/csharp/RSPEC-1186