Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

feat: add avoid-substring rule #1206

Merged
merged 1 commit into from
Mar 17, 2023
Merged

feat: add avoid-substring rule #1206

merged 1 commit into from
Mar 17, 2023

Conversation

lsaudon
Copy link
Contributor

@lsaudon lsaudon commented Mar 11, 2023

Issue: #1201

  • Read the contributing guidelines.
  • Followed lint naming conventions
  • Tests pass locally
  • Updated the changelog
  • Added the docs to this PR

Rule documentation

Replace s.substring(100,200) to s.characters.getRange(100,200).

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 [substring does not support UTF-16](https://github.com/dart-lang/sdk/issues/35798).

Good example

s.characters.getRange(14, 15); 

Bad example

s.substring(14, 15); 

@codecov
Copy link

codecov bot commented Mar 11, 2023

Codecov Report

Merging #1206 (9362821) into master (96001b5) will increase coverage by 0.03%.
The diff coverage is 100.00%.

❗ Current head 9362821 differs from pull request most recent head 0c6df2f. Consider uploading reports for the commit 0c6df2f to get more accurate results

@@            Coverage Diff             @@
##           master    #1206      +/-   ##
==========================================
+ Coverage   86.21%   86.24%   +0.03%     
==========================================
  Files         359      361       +2     
  Lines        8133     8152      +19     
==========================================
+ Hits         7012     7031      +19     
  Misses       1121     1121              
Impacted Files Coverage Δ
...c/analyzers/lint_analyzer/rules/rules_factory.dart 100.00% <ø> (ø)
...les_list/avoid_substring/avoid_substring_rule.dart 100.00% <100.00%> (ø)
...yzer/rules/rules_list/avoid_substring/visitor.dart 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@incendial incendial self-requested a review March 17, 2023 11:42
@incendial incendial added type: enhancement New feature or request area-rules labels Mar 17, 2023
@incendial incendial added this to the 5.7.0 milestone Mar 17, 2023
Copy link
Member

@incendial incendial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. If you'd like to have a Teams version license for 6 months, let me know.

@incendial incendial merged commit 85be501 into dart-code-checker:master Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-rules type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants