sonar-delphi
sonar-delphi copied to clipboard
New rule: StrUtils should be preferred over 'Copy'
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
Should use 'LeftStr' instead of 'Copy' from start
Rule description
Using Copy(Text, 1, Count)
is the equivalent of using LeftStr(Text, Count)
but impacts readability and making the intention harder to understand. Using LeftStr
conveys intention better.
Rationale
Seeing many Copy
used in different context makes it harder to understand the intention of its usage. By removing a sizeable chunk of generic Copy(Text, 1, Count)
, it makes it easier to focus on where other usage of Copy
does matter.