integrated-application-development / sonar-delphi

Delphi language plugin for SonarQube
GNU Lesser General Public License v3.0
104 stars 15 forks source link

Add quick fixes for `LowercaseKeywordCheck` #264

Closed denieu closed 3 months ago

denieu commented 4 months ago

This PR add "Correct to %s" quick fix for LowercaseKeywordCheck rule, in a similar way to what already exists for the MixedNamesCheck rule.

fourls commented 4 months ago

Hi @denieu, thanks for this PR - it's a good addition! There's a fair few rules that are good candidates for an easy quick fix, and this one will be very helpful.

Just thought I'd jump in because the quick fix comment syntax is a little unclear, and it's not documented anywhere at the moment.

This test is failing because you're asserting that there's one quick fix with two text edits, when there's actually two quick fixes with one text edit each. To assert there's two separate quick fixes you need to supply an identifier before the @ - here's an example from the FormatArgumentCount test:

https://github.com/integrated-application-development/sonar-delphi/blob/58a870ff4923d88c7c9e9ddafb063c80271fda1c/delphi-checks/src/test/java/au/com/integradev/delphi/checks/FormatArgumentCountCheckTest.java#L95-L96

qf1 and qf2 are just identifiers I came up with, there's no special meaning to them.

You could also make a separate test for each type of issue you'd like to assert a quick fix for.

denieu commented 4 months ago

Thanks @fourls, saved me a few hours of debugging😁, now it works as expected.