sonar-delphi icon indicating copy to clipboard operation
sonar-delphi copied to clipboard

New rule: Method parameters should comply with a naming convention

Open fourls opened this issue 2 years ago • 1 comments

Prerequisites

  • [x] This rule has not already been suggested.
  • [x] This should be a new rule, not an improvement to an existing rule.
  • [x] This rule would be generally useful, not specific to my code or setup.

Suggested rule title

Method parameters should comply with a naming convention

Rule description

This rule will check if a method parameter is in PascalCase and (optionally) has a certain prefix. The prefix will default to nothing.

Rationale

It's a common Delphi convention to prefix arguments with A, like in the example below:

procedure Example(AMyInt: string);
var
  MyStr: string;
begin
  // ...
end;

This would enforce this convention in the same way similar conventions are supported for other language constructs (type names, constant names, etc.).

fourls avatar Oct 24 '23 05:10 fourls

This would be a useful rule. It would also be pretty easy to implement, using the existing *NameCheck naming convention rules as reference points.

cirras avatar Nov 14 '23 03:11 cirras