Skip to content

Commit 281c73a

Browse files
yhirano55eregon
authored andcommitted
Update Rubocop to v0.54.0
- Update rubocop version in .travis.yml - Fix rubocop offenses: - Lint/BigDecimalNew - BigDecimal.new() is deprecated since BigDecimal 1.3.3 for Ruby 2.5 - So it worth to enable, I think. - Re-execute `rubocop --auto-gen-config`
1 parent f6a59dc commit 281c73a

File tree

10 files changed

+81
-80
lines changed

10 files changed

+81
-80
lines changed

.rubocop_todo.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2017-12-15 22:14:22 +0900 using RuboCop version 0.52.0.
3+
# on 2018-04-03 22:23:59 +0900 using RuboCop version 0.54.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -20,11 +20,6 @@ Lint/DuplicateMethods:
2020
- 'core/unboundmethod/fixtures/classes.rb'
2121
- 'fixtures/class.rb'
2222

23-
# Offense count: 4
24-
Lint/EmptyWhen:
25-
Exclude:
26-
- 'language/case_spec.rb'
27-
2823
# Offense count: 5
2924
Lint/EnsureReturn:
3025
Exclude:
@@ -43,7 +38,7 @@ Lint/FormatParameterMismatch:
4338
- 'core/kernel/shared/sprintf.rb'
4439
- 'core/string/modulo_spec.rb'
4540

46-
# Offense count: 28
41+
# Offense count: 29
4742
Lint/HandleExceptions:
4843
Enabled: false
4944

@@ -59,7 +54,7 @@ Lint/IneffectiveAccessModifier:
5954
- 'core/module/fixtures/classes.rb'
6055
- 'language/fixtures/private.rb'
6156

62-
# Offense count: 5
57+
# Offense count: 6
6358
# Cop supports --auto-correct.
6459
# Configuration parameters: EnforcedStyle.
6560
# SupportedStyles: runtime_error, standard_error
@@ -69,13 +64,13 @@ Lint/InheritException:
6964
- 'core/exception/fixtures/common.rb'
7065
- 'core/module/fixtures/autoload_ex1.rb'
7166

72-
# Offense count: 3
67+
# Offense count: 5
7368
# Cop supports --auto-correct.
7469
Lint/LiteralInInterpolation:
7570
Exclude:
71+
- 'core/module/refine_spec.rb'
7672
- 'language/defined_spec.rb'
7773
- 'language/fixtures/squiggly_heredoc.rb'
78-
- 'core/module/refine_spec.rb'
7974

8075
# Offense count: 16
8176
Lint/Loop:
@@ -105,7 +100,7 @@ Lint/RedundantWithIndex:
105100
Exclude:
106101
- 'core/enumerator/with_index_spec.rb'
107102

108-
# Offense count: 24
103+
# Offense count: 26
109104
Lint/RescueException:
110105
Exclude:
111106
- 'command_line/fixtures/debug_info.rb'
@@ -200,3 +195,9 @@ Lint/UselessAccessModifier:
200195
- 'core/module/module_function_spec.rb'
201196
- 'core/module/private_class_method_spec.rb'
202197
- 'language/fixtures/send.rb'
198+
199+
# Offense count: 6186
200+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
201+
# URISchemes: http, https
202+
Metrics/LineLength:
203+
Max: 588

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ matrix:
1717
- env: RUBOCOP=true
1818
rvm: 2.4.4
1919
script:
20-
- gem install rubocop -v 0.52.0
20+
- gem install rubocop -v 0.54.0
2121
- rubocop
2222
allow_failures:
2323
- rvm: ruby-head

core/time/at_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
describe "passed BigDecimal" do
3535
it "doesn't round input value" do
3636
require 'bigdecimal'
37-
Time.at(BigDecimal.new('1.1')).to_f.should == 1.1
37+
Time.at(BigDecimal('1.1')).to_f.should == 1.1
3838
end
3939
end
4040
end

library/bigdecimal/divmod_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BigDecimal
3636
it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod
3737

3838
it "raises ZeroDivisionError if other is zero" do
39-
bd5667 = BigDecimal.new("5667.19")
39+
bd5667 = BigDecimal("5667.19")
4040

4141
lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
4242
lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
@@ -96,8 +96,8 @@ class BigDecimal
9696

9797
it "can be reversed with * and +" do
9898
# Example taken from BigDecimal documentation
99-
a = BigDecimal.new("42")
100-
b = BigDecimal.new("9")
99+
a = BigDecimal("42")
100+
b = BigDecimal("9")
101101
q, m = a.divmod(b)
102102
c = q * b + m
103103
a.should == c

library/bigdecimal/inspect_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
describe "BigDecimal#inspect" do
55

66
before :each do
7-
@bigdec = BigDecimal.new("1234.5678")
7+
@bigdec = BigDecimal("1234.5678")
88
end
99

1010
it "returns String" do

library/bigdecimal/new_spec.rb

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,102 +4,102 @@
44
describe "BigDecimal.new" do
55

66
it "creates a new object of class BigDecimal" do
7-
BigDecimal.new("3.14159").should be_kind_of(BigDecimal)
7+
BigDecimal("3.14159").should be_kind_of(BigDecimal)
88
(0..9).each {|i|
9-
BigDecimal.new("1#{i}").should == 10 + i
10-
BigDecimal.new("-1#{i}").should == -10 - i
11-
BigDecimal.new("1E#{i}").should == 10**i
12-
BigDecimal.new("1000000E-#{i}").should == 10**(6-i).to_f
9+
BigDecimal("1#{i}").should == 10 + i
10+
BigDecimal("-1#{i}").should == -10 - i
11+
BigDecimal("1E#{i}").should == 10**i
12+
BigDecimal("1000000E-#{i}").should == 10**(6-i).to_f
1313
# ^ to_f to avoid Rational type
1414
}
1515
(1..9).each {|i|
16-
BigDecimal.new("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i
17-
BigDecimal.new("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i
16+
BigDecimal("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i
17+
BigDecimal("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i
1818
}
1919
end
2020

2121
it "accepts significant digits >= given precision" do
22-
BigDecimal.new("3.1415923", 10).precs[1].should >= 10
22+
BigDecimal("3.1415923", 10).precs[1].should >= 10
2323
end
2424

2525
it "determines precision from initial value" do
2626
pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043"
27-
BigDecimal.new(pi_string).precs[1].should >= pi_string.size-1
27+
BigDecimal(pi_string).precs[1].should >= pi_string.size-1
2828
end
2929

3030
it "ignores leading whitespace" do
31-
BigDecimal.new(" \t\n \r1234").should == BigDecimal.new("1234")
32-
BigDecimal.new(" \t\n \rNaN \n").nan?.should == true
33-
BigDecimal.new(" \t\n \rInfinity \n").infinite?.should == 1
34-
BigDecimal.new(" \t\n \r-Infinity \n").infinite?.should == -1
31+
BigDecimal(" \t\n \r1234").should == BigDecimal("1234")
32+
BigDecimal(" \t\n \rNaN \n").nan?.should == true
33+
BigDecimal(" \t\n \rInfinity \n").infinite?.should == 1
34+
BigDecimal(" \t\n \r-Infinity \n").infinite?.should == -1
3535
end
3636

3737
it "ignores trailing garbage" do
38-
BigDecimal.new("123E45ruby").should == BigDecimal.new("123E45")
39-
BigDecimal.new("123x45").should == BigDecimal.new("123")
40-
BigDecimal.new("123.4%E5").should == BigDecimal.new("123.4")
41-
BigDecimal.new("1E2E3E4E5E").should == BigDecimal.new("100")
38+
BigDecimal("123E45ruby").should == BigDecimal("123E45")
39+
BigDecimal("123x45").should == BigDecimal("123")
40+
BigDecimal("123.4%E5").should == BigDecimal("123.4")
41+
BigDecimal("1E2E3E4E5E").should == BigDecimal("100")
4242
end
4343

4444
ruby_version_is ""..."2.4" do
4545
it "treats invalid strings as 0.0" do
46-
BigDecimal.new("ruby").should == BigDecimal.new("0.0")
47-
BigDecimal.new(" \t\n \r-\t\t\tInfinity \n").should == BigDecimal.new("0.0")
46+
BigDecimal("ruby").should == BigDecimal("0.0")
47+
BigDecimal(" \t\n \r-\t\t\tInfinity \n").should == BigDecimal("0.0")
4848
end
4949
end
5050

5151
ruby_version_is "2.4" do
5252
it "raises ArgumentError for invalid strings" do
53-
lambda { BigDecimal.new("ruby") }.should raise_error(ArgumentError)
54-
lambda { BigDecimal.new(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError)
53+
lambda { BigDecimal("ruby") }.should raise_error(ArgumentError)
54+
lambda { BigDecimal(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError)
5555
end
5656
end
5757

5858
it "allows omitting the integer part" do
59-
BigDecimal.new(".123").should == BigDecimal.new("0.123")
59+
BigDecimal(".123").should == BigDecimal("0.123")
6060
end
6161

6262
it "allows for underscores in all parts" do
63-
reference = BigDecimal.new("12345.67E89")
63+
reference = BigDecimal("12345.67E89")
6464

65-
BigDecimal.new("12_345.67E89").should == reference
66-
BigDecimal.new("1_2_3_4_5_._6____7_E89").should == reference
67-
BigDecimal.new("12345_.67E_8__9_").should == reference
65+
BigDecimal("12_345.67E89").should == reference
66+
BigDecimal("1_2_3_4_5_._6____7_E89").should == reference
67+
BigDecimal("12345_.67E_8__9_").should == reference
6868
end
6969

7070
it "accepts NaN and [+-]Infinity" do
71-
BigDecimal.new("NaN").nan?.should == true
71+
BigDecimal("NaN").nan?.should == true
7272

73-
pos_inf = BigDecimal.new("Infinity")
73+
pos_inf = BigDecimal("Infinity")
7474
pos_inf.finite?.should == false
7575
pos_inf.should > 0
76-
pos_inf.should == BigDecimal.new("+Infinity")
76+
pos_inf.should == BigDecimal("+Infinity")
7777

78-
neg_inf = BigDecimal.new("-Infinity")
78+
neg_inf = BigDecimal("-Infinity")
7979
neg_inf.finite?.should == false
8080
neg_inf.should < 0
8181
end
8282

8383
it "allows for [eEdD] as exponent separator" do
84-
reference = BigDecimal.new("12345.67E89")
84+
reference = BigDecimal("12345.67E89")
8585

86-
BigDecimal.new("12345.67e89").should == reference
87-
BigDecimal.new("12345.67E89").should == reference
88-
BigDecimal.new("12345.67d89").should == reference
89-
BigDecimal.new("12345.67D89").should == reference
86+
BigDecimal("12345.67e89").should == reference
87+
BigDecimal("12345.67E89").should == reference
88+
BigDecimal("12345.67d89").should == reference
89+
BigDecimal("12345.67D89").should == reference
9090
end
9191

9292
it "allows for varying signs" do
93-
reference = BigDecimal.new("123.456E1")
94-
95-
BigDecimal.new("+123.456E1").should == reference
96-
BigDecimal.new("-123.456E1").should == -reference
97-
BigDecimal.new("123.456E+1").should == reference
98-
BigDecimal.new("12345.6E-1").should == reference
99-
BigDecimal.new("+123.456E+1").should == reference
100-
BigDecimal.new("+12345.6E-1").should == reference
101-
BigDecimal.new("-123.456E+1").should == -reference
102-
BigDecimal.new("-12345.6E-1").should == -reference
93+
reference = BigDecimal("123.456E1")
94+
95+
BigDecimal("+123.456E1").should == reference
96+
BigDecimal("-123.456E1").should == -reference
97+
BigDecimal("123.456E+1").should == reference
98+
BigDecimal("12345.6E-1").should == reference
99+
BigDecimal("+123.456E+1").should == reference
100+
BigDecimal("+12345.6E-1").should == reference
101+
BigDecimal("-123.456E+1").should == -reference
102+
BigDecimal("-12345.6E-1").should == -reference
103103
end
104104

105105
it 'raises ArgumentError when Float is used without precision' do

library/bigdecimal/shared/eql.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
describe :bigdecimal_eql, shared: true do
44
before :each do
5-
@bg6543_21 = BigDecimal.new("6543.21")
6-
@bg5667_19 = BigDecimal.new("5667.19")
5+
@bg6543_21 = BigDecimal("6543.21")
6+
@bg5667_19 = BigDecimal("5667.19")
77
@a = BigDecimal("1.0000000000000000000000000000000000000000005")
88
@b = BigDecimal("1.00000000000000000000000000000000000000000005")
99
@bigint = BigDecimal("1000.0")

library/bigdecimal/shared/modulo.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
end
1919

2020
it "returns self modulo other" do
21-
bd6543 = BigDecimal.new("6543.21")
22-
bd5667 = BigDecimal.new("5667.19")
21+
bd6543 = BigDecimal("6543.21")
22+
bd5667 = BigDecimal("5667.19")
2323
a = BigDecimal("1.0000000000000000000000000000000000000000005")
2424
b = BigDecimal("1.00000000000000000000000000000000000000000005")
2525

@@ -107,7 +107,7 @@
107107

108108
describe :bigdecimal_modulo_zerodivisionerror, shared: true do
109109
it "raises ZeroDivisionError if other is zero" do
110-
bd5667 = BigDecimal.new("5667.19")
110+
bd5667 = BigDecimal("5667.19")
111111

112112
lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
113113
lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)

library/bigdecimal/to_r_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
end
99

1010
it "returns a Rational with bignum values" do
11-
r = BigDecimal.new("3.141592653589793238462643").to_r
11+
r = BigDecimal("3.141592653589793238462643").to_r
1212
r.numerator.should eql(3141592653589793238462643)
1313
r.denominator.should eql(1000000000000000000000000)
1414
end

library/bigdecimal/to_s_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
@bigdec.to_s(3).should =~ re
3535

3636
str1 = '-123.45678 90123 45678 9'
37-
BigDecimal.new("-123.45678901234567890").to_s('5F').should == str1
37+
BigDecimal("-123.45678901234567890").to_s('5F').should == str1
3838
# trailing zeroes removed
39-
BigDecimal.new("1.00000000000").to_s('1F').should == "1.0"
39+
BigDecimal("1.00000000000").to_s('1F').should == "1.0"
4040
# 0 is treated as no spaces
41-
BigDecimal.new("1.2345").to_s('0F').should == "1.2345"
41+
BigDecimal("1.2345").to_s('0F').should == "1.2345"
4242
end
4343

4444
it "can return a leading space for values > 0" do
@@ -47,15 +47,15 @@
4747
end
4848

4949
it "removes trailing spaces in floating point notation" do
50-
BigDecimal.new('-123.45678901234567890').to_s('F').should == "-123.4567890123456789"
51-
BigDecimal.new('1.2500').to_s('F').should == "1.25"
52-
BigDecimal.new('0000.00000').to_s('F').should == "0.0"
53-
BigDecimal.new('-00.000010000').to_s('F').should == "-0.00001"
54-
BigDecimal.new("5.00000E-2").to_s("F").should == "0.05"
50+
BigDecimal('-123.45678901234567890').to_s('F').should == "-123.4567890123456789"
51+
BigDecimal('1.2500').to_s('F').should == "1.25"
52+
BigDecimal('0000.00000').to_s('F').should == "0.0"
53+
BigDecimal('-00.000010000').to_s('F').should == "-0.00001"
54+
BigDecimal("5.00000E-2").to_s("F").should == "0.05"
5555

56-
BigDecimal.new("500000").to_s("F").should == "500000.0"
57-
BigDecimal.new("5E2").to_s("F").should == "500.0"
58-
BigDecimal.new("-5E100").to_s("F").should == "-5" + "0" * 100 + ".0"
56+
BigDecimal("500000").to_s("F").should == "500000.0"
57+
BigDecimal("5E2").to_s("F").should == "500.0"
58+
BigDecimal("-5E100").to_s("F").should == "-5" + "0" * 100 + ".0"
5959
end
6060

6161
it "can use engineering notation" do
@@ -66,7 +66,7 @@
6666
@bigdec.to_s("F").should == @bigdec_str
6767
@bigneg.to_s("F").should == @bigneg_str
6868
str2 = "+123.45678901 23456789"
69-
BigDecimal.new('123.45678901234567890').to_s('+8F').should == str2
69+
BigDecimal('123.45678901234567890').to_s('+8F').should == str2
7070
end
7171

7272
end

0 commit comments

Comments
 (0)