dart-code-checker / dart-code-metrics

Software analytics tool that helps developers analyse and improve software quality.
https://dcm.dev
Other
860 stars 265 forks source link

[New rule] avoid-substring #1201

Closed fzyzcjy closed 1 year ago

fzyzcjy commented 1 year ago

Rule details

As we know, using String.substring method will cause problems if you are having emojis in the string. There are many articles in the web, such as https://github.com/dart-lang/sdk/issues/35798. Users should replace s.substring(100,200) with s.characters.getRange(100,200).

What type of rule is this?

Warns about a potential problem

Example code

s.substring(100,200); // LINT


### Participation

- [ ] I am willing to submit a pull request to implement this rule.

### Additional comments

_No response_
incendial commented 1 year ago

@fzyzcjy do you want to implement it yourself? If not, all new rules implemented by me are added to the Teams version only.

incendial commented 1 year ago

I'd also be happy to give you the Teams version license for your effort on DCM. If you're interested, please mail me at incendial@dcm.dev

fzyzcjy commented 1 year ago

@incendial Hi, I do not have a strong need for the Teams license currently, but thanks for providing the license to me!

lsaudon commented 1 year ago

I'm going to do it.

incendial commented 1 year ago

Available in 5.7.0 🚀