integrated-application-development / integrated-application-development/sonar-delphi
New rule: StrUtils should be preferred over 'Copy'
- Dominant language
- Java
- Stars
- 159
- Forks
- 31
- Avg merge
- 5d 4h
- Merged PRs (30d)
- 4
Description
### 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.
Contributor guide
Assessment
This issue has not been assessed yet.