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

Style/NumericLiterals-20230601233307 #214

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jun 1, 2023

Rubocop challenge!

Style/NumericLiterals

Safe autocorrect: Yes
✅ The autocorrect a cop does is safe (equivalent) by design.

Description

Overview

Checks for big numeric literals without _ between groups
of digits in them.

Additional allowed patterns can be added by adding regexps to
the AllowedPatterns configuration. All regexps are treated
as anchored even if the patterns do not contain anchors (so
\d{4}_\d{4} will allow 1234_5678 but not 1234_5678_9012).

NOTE: Even if AllowedPatterns are given, autocorrection will
only correct to the standard pattern of an _ every 3 digits.

Examples

# bad
1000000
1_00_000
1_0000

# good
1_000_000
1000

Strict: false (default)

# good
10_000_00 # typical representation of $10,000 in cents

Strict: true

# bad
10_000_00 # typical representation of $10,000 in cents

AllowedNumbers: [3000]

# good
3000 # You can specify allowed numbers. (e.g. port number)

Auto generated by rubocop_challenger

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

Successfully merging this pull request may close these issues.

0 participants