Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: StrUtils should be preferred over 'Copy' #283

Open
3 tasks done
Skarvion opened this issue Aug 12, 2024 · 1 comment
Open
3 tasks done

New rule: StrUtils should be preferred over 'Copy' #283

Skarvion opened this issue Aug 12, 2024 · 1 comment
Labels
feature New feature or request rule Improvements or additions to rules

Comments

@Skarvion
Copy link

Prerequisites

  • This rule has not already been suggested.
  • This should be a new rule, not an improvement to an existing rule.
  • 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.

@Skarvion Skarvion added feature New feature or request rule Improvements or additions to rules triage This needs to be triaged by a maintainer labels Aug 12, 2024
@Skarvion Skarvion changed the title Should use LeftStr(Text, Count) instead of Copy(Text, 1, Count) New rule: Should use LeftStr(Text, Count) instead of Copy(Text, 1, Count) Aug 12, 2024
@Cirras
Copy link
Collaborator

Cirras commented Aug 12, 2024

Sounds more like a StrUtils should be preferred over 'Copy' rule, given that there are multiple StrUtils routines that just use Copy under the hood.

Those routines are:

  • LeftStr
  • RightStr
  • MidStr

MidStr is a bit funny, it's a braindead wrapper around Copy that just directly forwards the arguments.

I think this rule has some value for consistency purposes primarily, but it's on the nitpicky side. I wouldn't want it to be included in the default quality profile.

@Cirras Cirras changed the title New rule: Should use LeftStr(Text, Count) instead of Copy(Text, 1, Count) New rule: StrUtils should be preferred over 'Copy' Aug 12, 2024
@Cirras Cirras removed the triage This needs to be triaged by a maintainer label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request rule Improvements or additions to rules
Projects
None yet
Development

No branches or pull requests

2 participants