integrated-application-development / integrated-application-development/sonar-delphi

New rule: StrUtils should be preferred over 'Copy'

Open
#283 2 comments 0 reactions 0 assignees View on GitHub
feature rule
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.