2222 */
2323package au .com .integradev .delphi .checks ;
2424
25+ import com .google .common .base .Splitter ;
26+ import com .google .common .collect .ImmutableSortedSet ;
2527import java .util .List ;
28+ import java .util .Set ;
2629import org .apache .commons .lang3 .StringUtils ;
2730import org .sonar .check .Rule ;
31+ import org .sonar .check .RuleProperty ;
2832import org .sonar .plugins .communitydelphi .api .ast .ArgumentListNode ;
2933import org .sonar .plugins .communitydelphi .api .ast .AttributeNode ;
3034import org .sonar .plugins .communitydelphi .api .ast .DelphiNode ;
@@ -48,12 +52,30 @@ public class MixedNamesCheck extends DelphiCheck {
4852 private static final String MESSAGE = "Avoid mixing names (found: \" %s\" expected: \" %s\" )." ;
4953 private static final String QUICK_FIX_MESSAGE = "Correct to \" %s\" " ;
5054
55+ private Set <String > excludedSet ;
56+
57+ @ RuleProperty (
58+ key = "excludedNames" ,
59+ description = "List of names to ignore, separated by a comma." )
60+ public String excludedNames = "" ;
61+
62+ @ Override
63+ public void start (DelphiCheckContext context ) {
64+ excludedSet =
65+ ImmutableSortedSet .copyOf (
66+ String .CASE_INSENSITIVE_ORDER , Splitter .on (',' ).trimResults ().split (excludedNames ));
67+ }
68+
5169 @ Override
5270 public DelphiCheckContext visit (NameReferenceNode reference , DelphiCheckContext context ) {
5371 NameDeclaration declaration = reference .getNameDeclaration ();
5472 NameOccurrence occurrence = reference .getNameOccurrence ();
5573
5674 if (declaration != null ) {
75+ if (excludedSet .contains (occurrence .getImage ())) {
76+ return context ;
77+ }
78+
5779 if (declaration instanceof UnitImportNameDeclaration ) {
5880 // Checks the occurrence against the original unit declaration instead of the import
5981 // declaration
0 commit comments