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

Update Rubocop to v0.54.0 #593

Merged
merged 2 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-12-15 22:14:22 +0900 using RuboCop version 0.52.0.
# on 2018-04-03 22:23:59 +0900 using RuboCop version 0.54.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -20,11 +20,6 @@ Lint/DuplicateMethods:
- 'core/unboundmethod/fixtures/classes.rb'
- 'fixtures/class.rb'

# Offense count: 4
Lint/EmptyWhen:
Exclude:
- 'language/case_spec.rb'

# Offense count: 5
Lint/EnsureReturn:
Exclude:
Expand All @@ -43,7 +38,7 @@ Lint/FormatParameterMismatch:
- 'core/kernel/shared/sprintf.rb'
- 'core/string/modulo_spec.rb'

# Offense count: 28
# Offense count: 29
Lint/HandleExceptions:
Enabled: false

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

# Offense count: 5
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: runtime_error, standard_error
Expand All @@ -69,13 +64,13 @@ Lint/InheritException:
- 'core/exception/fixtures/common.rb'
- 'core/module/fixtures/autoload_ex1.rb'

# Offense count: 3
# Offense count: 5
# Cop supports --auto-correct.
Lint/LiteralInInterpolation:
Exclude:
- 'core/module/refine_spec.rb'
- 'language/defined_spec.rb'
- 'language/fixtures/squiggly_heredoc.rb'
- 'core/module/refine_spec.rb'

# Offense count: 16
Lint/Loop:
Expand Down Expand Up @@ -105,7 +100,7 @@ Lint/RedundantWithIndex:
Exclude:
- 'core/enumerator/with_index_spec.rb'

# Offense count: 24
# Offense count: 26
Lint/RescueException:
Exclude:
- 'command_line/fixtures/debug_info.rb'
Expand Down Expand Up @@ -200,3 +195,9 @@ Lint/UselessAccessModifier:
- 'core/module/module_function_spec.rb'
- 'core/module/private_class_method_spec.rb'
- 'language/fixtures/send.rb'

# Offense count: 6186
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 588
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ matrix:
- env: RUBOCOP=true
rvm: 2.4.4
script:
- gem install rubocop -v 0.52.0
- gem install rubocop -v 0.54.0
- rubocop
allow_failures:
- rvm: ruby-head
Expand Down
2 changes: 1 addition & 1 deletion core/time/at_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
describe "passed BigDecimal" do
it "doesn't round input value" do
require 'bigdecimal'
Time.at(BigDecimal.new('1.1')).to_f.should == 1.1
Time.at(BigDecimal('1.1')).to_f.should == 1.1
end
end
end
Expand Down
109 changes: 109 additions & 0 deletions library/bigdecimal/BigDecimal_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
require_relative '../../spec_helper'
require 'bigdecimal'

describe "Kernel#BigDecimal" do

it "creates a new object of class BigDecimal" do
BigDecimal("3.14159").should be_kind_of(BigDecimal)
(0..9).each {|i|
BigDecimal("1#{i}").should == 10 + i
BigDecimal("-1#{i}").should == -10 - i
BigDecimal("1E#{i}").should == 10**i
BigDecimal("1000000E-#{i}").should == 10**(6-i).to_f
# ^ to_f to avoid Rational type
}
(1..9).each {|i|
BigDecimal("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i
BigDecimal("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i
}
end

it "accepts significant digits >= given precision" do
BigDecimal("3.1415923", 10).precs[1].should >= 10
end

it "determines precision from initial value" do
pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043"
BigDecimal(pi_string).precs[1].should >= pi_string.size-1
end

it "ignores leading whitespace" do
BigDecimal(" \t\n \r1234").should == BigDecimal("1234")
BigDecimal(" \t\n \rNaN \n").nan?.should == true
BigDecimal(" \t\n \rInfinity \n").infinite?.should == 1
BigDecimal(" \t\n \r-Infinity \n").infinite?.should == -1
end

it "ignores trailing garbage" do
BigDecimal("123E45ruby").should == BigDecimal("123E45")
BigDecimal("123x45").should == BigDecimal("123")
BigDecimal("123.4%E5").should == BigDecimal("123.4")
BigDecimal("1E2E3E4E5E").should == BigDecimal("100")
end

ruby_version_is ""..."2.4" do
it "treats invalid strings as 0.0" do
BigDecimal("ruby").should == BigDecimal("0.0")
BigDecimal(" \t\n \r-\t\t\tInfinity \n").should == BigDecimal("0.0")
end
end

ruby_version_is "2.4" do
it "raises ArgumentError for invalid strings" do
lambda { BigDecimal("ruby") }.should raise_error(ArgumentError)
lambda { BigDecimal(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError)
end
end

it "allows omitting the integer part" do
BigDecimal(".123").should == BigDecimal("0.123")
end

it "allows for underscores in all parts" do
reference = BigDecimal("12345.67E89")

BigDecimal("12_345.67E89").should == reference
BigDecimal("1_2_3_4_5_._6____7_E89").should == reference
BigDecimal("12345_.67E_8__9_").should == reference
end

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

pos_inf = BigDecimal("Infinity")
pos_inf.finite?.should == false
pos_inf.should > 0
pos_inf.should == BigDecimal("+Infinity")

neg_inf = BigDecimal("-Infinity")
neg_inf.finite?.should == false
neg_inf.should < 0
end

it "allows for [eEdD] as exponent separator" do
reference = BigDecimal("12345.67E89")

BigDecimal("12345.67e89").should == reference
BigDecimal("12345.67E89").should == reference
BigDecimal("12345.67d89").should == reference
BigDecimal("12345.67D89").should == reference
end

it "allows for varying signs" do
reference = BigDecimal("123.456E1")

BigDecimal("+123.456E1").should == reference
BigDecimal("-123.456E1").should == -reference
BigDecimal("123.456E+1").should == reference
BigDecimal("12345.6E-1").should == reference
BigDecimal("+123.456E+1").should == reference
BigDecimal("+12345.6E-1").should == reference
BigDecimal("-123.456E+1").should == -reference
BigDecimal("-12345.6E-1").should == -reference
end

it 'raises ArgumentError when Float is used without precision' do
lambda { BigDecimal(1.0) }.should raise_error(ArgumentError)
end

end
6 changes: 3 additions & 3 deletions library/bigdecimal/divmod_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BigDecimal
it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod

it "raises ZeroDivisionError if other is zero" do
bd5667 = BigDecimal.new("5667.19")
bd5667 = BigDecimal("5667.19")

lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
Expand Down Expand Up @@ -96,8 +96,8 @@ class BigDecimal

it "can be reversed with * and +" do
# Example taken from BigDecimal documentation
a = BigDecimal.new("42")
b = BigDecimal.new("9")
a = BigDecimal("42")
b = BigDecimal("9")
q, m = a.divmod(b)
c = q * b + m
a.should == c
Expand Down
2 changes: 1 addition & 1 deletion library/bigdecimal/inspect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe "BigDecimal#inspect" do

before :each do
@bigdec = BigDecimal.new("1234.5678")
@bigdec = BigDecimal("1234.5678")
end

it "returns String" do
Expand Down
109 changes: 0 additions & 109 deletions library/bigdecimal/new_spec.rb

This file was deleted.

4 changes: 2 additions & 2 deletions library/bigdecimal/shared/eql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

describe :bigdecimal_eql, shared: true do
before :each do
@bg6543_21 = BigDecimal.new("6543.21")
@bg5667_19 = BigDecimal.new("5667.19")
@bg6543_21 = BigDecimal("6543.21")
@bg5667_19 = BigDecimal("5667.19")
@a = BigDecimal("1.0000000000000000000000000000000000000000005")
@b = BigDecimal("1.00000000000000000000000000000000000000000005")
@bigint = BigDecimal("1000.0")
Expand Down
6 changes: 3 additions & 3 deletions library/bigdecimal/shared/modulo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
end

it "returns self modulo other" do
bd6543 = BigDecimal.new("6543.21")
bd5667 = BigDecimal.new("5667.19")
bd6543 = BigDecimal("6543.21")
bd5667 = BigDecimal("5667.19")
a = BigDecimal("1.0000000000000000000000000000000000000000005")
b = BigDecimal("1.00000000000000000000000000000000000000000005")

Expand Down Expand Up @@ -107,7 +107,7 @@

describe :bigdecimal_modulo_zerodivisionerror, shared: true do
it "raises ZeroDivisionError if other is zero" do
bd5667 = BigDecimal.new("5667.19")
bd5667 = BigDecimal("5667.19")

lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
Expand Down
2 changes: 1 addition & 1 deletion library/bigdecimal/to_r_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

it "returns a Rational with bignum values" do
r = BigDecimal.new("3.141592653589793238462643").to_r
r = BigDecimal("3.141592653589793238462643").to_r
r.numerator.should eql(3141592653589793238462643)
r.denominator.should eql(1000000000000000000000000)
end
Expand Down
Loading