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

Do not enable Style/Exponential Notation by default #12653

Open
stomar opened this issue Jan 25, 2024 · 2 comments
Open

Do not enable Style/Exponential Notation by default #12653

stomar opened this issue Jan 25, 2024 · 2 comments

Comments

@stomar
Copy link
Contributor

stomar commented Jan 25, 2024

For numbers in scientific notation, at least two different styles are widely used, normalized scientific notation and engineering notation. Enforcing one of those styles by default is IMO too intrusive.

lambda1 = 400e-9
distance = 12.5e-2

rubocop 1.60.2:

Style/ExponentialNotation: Use a mantissa in [1, 10[.

By default, the cop is enabled and enforces normalized scientific notation.
But depending on the field, engineering notation might be more common.
It might even make sense to use neither of those two (e-2 for distances in cm).

Enabling it by default makes it necessary to add yet another configuration setting.


Expected behavior

RuboCop should not report this by default, Style/Exponential Notation should be disabled.

Actual behavior

Style/Exponential Notation is enabled by default.

Steps to reproduce the problem

See example above.

RuboCop version

$ [bundle exec] rubocop -V
1.60.2 (using Parser 3.3.0.5, rubocop-ast 1.30.0, running on ruby 3.3.0) [x86_64-linux]
@stomar stomar added the bug label Jan 25, 2024
@koic koic removed the bug label Jan 26, 2024
@koic
Copy link
Member

koic commented Jan 26, 2024

Personally inclined to respect writer's intentions, this proposal seems acceptable.

@tdeo You have proposed the Style Guide rule rubocop/ruby-style-guide#811 and its implementation #7851 for this issue. Do you have any thoughts on this matter?

cc @rubocop/rubocop-core

@tdeo
Copy link
Contributor

tdeo commented Jan 26, 2024

While I don't have a strong personal attachment to the rule, I do believe consistency is king when it comes to using that notation to help the reader.

Given the very low amount of times this has been discussed over nearly 4 years, I do believe the current configuration is reasonable enough even though it won't please 100% of people

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants