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

Update/NumberToWords #29

Closed

Conversation

makhosravi
Copy link
Contributor

  • Updated NumberToWords algorithm
  • Added test cases
  • Removed method and extension for String type numbers to focus the feature on safe integer values, removed related examples and test cases
  • Added doc for methods and updated README.md

@codecov
Copy link

codecov bot commented Aug 30, 2021

Codecov Report

Merging #29 (1aece25) into dev (da5dc5c) will decrease coverage by 0.10%.
The diff coverage is 100.00%.

❗ Current head 1aece25 differs from pull request most recent head a1a0e9c. Consider uploading reports for the commit a1a0e9c to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##              dev      #29      +/-   ##
==========================================
- Coverage   96.02%   95.92%   -0.11%     
==========================================
  Files          42       42              
  Lines        2694     2649      -45     
==========================================
- Hits         2587     2541      -46     
- Misses        107      108       +1     
Impacted Files Coverage Δ
lib/src/core/number_to_words/number_to_words.dart 100.00% <100.00%> (ø)
test/test_number_to_words.dart 100.00% <100.00%> (ø)
lib/src/internal_methods.dart 75.00% <0.00%> (-12.50%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da5dc5c...a1a0e9c. Read the comment docs.

@payam-zahedi payam-zahedi requested review from EhsanAramide and payam-zahedi and removed request for EhsanAramide August 30, 2021 04:37
@payam-zahedi
Copy link
Member

@EhsanAramide Why we have broken codecov task here?

Copy link
Member

@payam-zahedi payam-zahedi left a comment

Choose a reason for hiding this comment

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

Well done @m-khooryani, I enjoyed spending time reviewing this clean code.
Check comments and apply your changes.

Comment on lines 34 to 36
if (number <= 9) {
return _getWord(number);
} else if (number >= 11 && number <= 19) return _getWord(number);
Copy link
Member

Choose a reason for hiding this comment

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

I think we can make these three lines more efficient and readable. Something like:

if ( number <=19 && number!=10 ) return _getWord(number);

Copy link
Member

Choose a reason for hiding this comment

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

Also, you can write comment to make it more understandable.

Comment on lines 31 to 39
/// Gets an [int] with 3 or less digits as input and converts it to persian
String? _transformToWord(int number) {
if (number == 0) return '';
Copy link
Member

Choose a reason for hiding this comment

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

I like the way this algorithm works.

}

/// Returns Persian word of the given number in int You can determine
/// returned string has ordinal suffix or not by `ordinal` flag.
String numberToWords(int number, {bool ordinal = false}) {
String? numberToWords(int number, {bool ordinal = false}) {
if (number == 0) return zeroFa;
Copy link
Member

Choose a reason for hiding this comment

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

You have checked this condition in multiple functions. I think you can only check it in _perform function.

}

/// Returns Persian word of the given number in int You can determine
/// returned string has ordinal suffix or not by `ordinal` flag.
String numberToWords(int number, {bool ordinal = false}) {
String? numberToWords(int number, {bool ordinal = false}) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for this method to return a null value? If not, we can make this null safe, and it would be a great improvement.

@EhsanAramide
Copy link
Contributor

@EhsanAramide Why we have broken codecov task here?

do you think does it have any relation with a deletion on lib/src/internal_methods.dart?

@payam-zahedi
Copy link
Member

do you think does it have any relation with a deletion on lib/src/internal_methods.dart?

I have no idea! The internal_method.dart file doesn't change in this PR.

… removed input string extension and method, made the methods null safe
Copy link
Member

@payam-zahedi payam-zahedi left a comment

Choose a reason for hiding this comment

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

Great work @makhosravi, You did everything good. We will try to fix the issue that we have in our CI/CD workflow. After that, we will merge this PR.

@makhosravi makhosravi force-pushed the update/number-to-words branch from 1aece25 to a1a0e9c Compare September 14, 2021 06:19
@ali-master ali-master added enhancement New feature or request feature refactor make code more readable and consistant labels Sep 14, 2021
@ali-master ali-master linked an issue Sep 14, 2021 that may be closed by this pull request
5 tasks
@EhsanAramide
Copy link
Contributor

We decided to close the pull request for some errors which occur in calculating delta test coverage, because of conflicts in compared heads' SHA.
Open another pull request again and for next time don't force-push the commit history.
Thanks for your contributions :octocat:.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature refactor make code more readable and consistant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

تغییرات اعمالی در نسخه‌ی جدید
4 participants