Merge pull request #258 from crystal-ameba/bump-large-numbers-min-int-digits

Bump default value of `LargeNumbers#int_min_digits` to 6
This commit is contained in:
Sijawusz Pur Rahnama 2022-03-08 14:48:45 +01:00 committed by GitHub
commit dad72341cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -6,6 +6,7 @@ module Ameba
private def it_transforms(number, expected)
it "transforms large number #{number}" do
rule = Rule::Style::LargeNumbers.new
rule.int_min_digits = 5
source = expect_issue rule, <<-CRYSTAL, number: number
number = %{number}

View file

@ -6,17 +6,17 @@ module Ameba::Rule::Style
# For example, these are considered invalid:
#
# ```
# 10000
# 100000
# 141592654
# 5.12345
# 5.123456
# ```
#
# And has to be rewritten as the following:
#
# ```
# 10_000
# 100_000
# 141_592_654
# 5.123_45
# 5.123_456
# ```
#
# YAML configuration example:
@ -24,13 +24,13 @@ module Ameba::Rule::Style
# ```
# Style/LargeNumbers:
# Enabled: true
# IntMinDigits: 5 # i.e. integers higher than 9999
# IntMinDigits: 6 # i.e. integers higher than 99999
# ```
class LargeNumbers < Base
properties do
enabled false
description "Disallows usage of large numbers without underscore"
int_min_digits 5
int_min_digits 6
end
MSG = "Large numbers should be written with underscores: %s"