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

Added a lint-fraction-readability flag to the configuration #6421

Merged

Conversation

xFrednet
Copy link
Member

@xFrednet xFrednet commented Dec 4, 2020

This adds an option to disable the unreadable_literal lint for floats with a longer fraction. This allows users to write 0.100200300 without getting a warning. Fixes #4176

I have some open questions about this PR:

  1. I've named the option lint-fraction-readability is this a good name or should I rename it to something else?
  2. What should the default configuration value be?
    • The current default value is true as this was also the previous default.
  3. Do I have to document this new option somewhere else or will it be extracted from the code comment?
  4. The current fix option will also rewrite the fraction if the integer part violates the unreadable_literal lint it would otherwise also trigger the inconsistent_digit_grouping lint. Is this also okay?
    • 1.100200300 will be unaffected by the fix function
    • 100200300.100200300 will be effected and fixed to 100_200_300.100_200_300

The project needed some getting used to but I'm happy with the result. A big thank you to @flip1995 for giving me some pointers for this implementation and to everyone for the great introduction documentation!


changelog: Added the unreadable-literal-lint-fractions configuration to disable the unreadable_literal lint for fractions

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 4, 2020
@Manishearth
Copy link
Member

I've named the option lint-fraction-readability is this a good name or should I rename it to something else?

i would have unreadable-literal in the name, so unreadable-literal-lint-fractions or something

  • What should the default configuration value be?

    • The current default value is true as this was also the previous default.
  • Do I have to document this new option somewhere else or will it be extracted from the code comment?

yes and yes

The current fix option will also rewrite the fraction if the integer part violates the unreadable_literal lint it would otherwise also trigger the inconsistent_digit_grouping lint. Is this also okay?

not sure what you mean here

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

overall looks good

@xFrednet
Copy link
Member Author

xFrednet commented Dec 5, 2020

The configuration was renamed to unreadable-literal-lint-fractions. I agree that that is a better name.

The 4th question was about the automatic suggestion if the lint gets violated for the integer part. I haven't changed the suggestion generation. This means that a number that violated the integer readability like 100200300.100200300 would also have separation in the fraction part. The suggestion for that number would be: 100_200_300.100_200_300. I believe that this is still a good thing to keep the number consistent.

@xFrednet xFrednet requested a review from Manishearth December 5, 2020 21:08
@Manishearth
Copy link
Member

The 4th question was about the automatic suggestion if the lint gets violated for the integer part. I haven't changed the suggestion generation. This means that a number that violated the integer readability like 100200300.100200300 would also have separation in the fraction part. The suggestion for that number would be: 100_200_300.100_200_300. I believe that this is still a good thing to keep the number consistent.

Oh. Yeah that seems fine, that's what I would expect.

@Manishearth
Copy link
Member

@bors r+

thanks!

@bors
Copy link
Contributor

bors commented Dec 6, 2020

📌 Commit 898b7c5 has been approved by Manishearth

@bors
Copy link
Contributor

bors commented Dec 6, 2020

⌛ Testing commit 898b7c5 with merge c1664c5...

@bors
Copy link
Contributor

bors commented Dec 6, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing c1664c5 to master...

@bors bors merged commit c1664c5 into rust-lang:master Dec 6, 2020
@xFrednet xFrednet deleted the 4176-unreadable-literal-lint-fractal-option branch July 28, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unreadable_literal for floating-point numbers
4 participants