Skip to content

Commit e6c56f6

Browse files
authored
Lint: Fix Lint cops (#1194)
1 parent 2b4961e commit e6c56f6

File tree

9 files changed

+19
-49
lines changed

9 files changed

+19
-49
lines changed

.rubocop_todo.yml

Lines changed: 2 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/money/bank/variable_exchange.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def exchange_with(from, to_currency, &)
112112
if from.currency == to_currency
113113
from
114114
else
115-
if rate = get_rate(from.currency, to_currency)
115+
if (rate = get_rate(from.currency, to_currency))
116116
fractional = calculate_fractional(from, to_currency)
117117
from.dup_with(
118118
fractional: exchange(fractional, rate, &),
@@ -175,7 +175,7 @@ def add_rate(from, to, rate)
175175
# bank = Money::Bank::VariableExchange.new
176176
# bank.set_rate("USD", "CAD", 1.24515)
177177
# bank.set_rate("CAD", "USD", 0.803115)
178-
def set_rate(from, to, rate, opts = {})
178+
def set_rate(from, to, rate, _opts = {})
179179
store.add_rate(Currency.wrap(from).iso_code, Currency.wrap(to).iso_code, rate)
180180
end
181181

@@ -196,7 +196,7 @@ def set_rate(from, to, rate, opts = {})
196196
#
197197
# bank.get_rate("USD", "CAD") #=> 1.24515
198198
# bank.get_rate("CAD", "USD") #=> 0.803115
199-
def get_rate(from, to, opts = {})
199+
def get_rate(from, to, _opts = {})
200200
store.get_rate(Currency.wrap(from).iso_code, Currency.wrap(to).iso_code)
201201
end
202202

@@ -219,7 +219,7 @@ def get_rate(from, to, opts = {})
219219
#
220220
# s = bank.export_rates(:json)
221221
# s #=> "{\"USD_TO_CAD\":1.24515,\"CAD_TO_USD\":0.803115}"
222-
def export_rates(format, file = nil, opts = {})
222+
def export_rates(format, file = nil, _opts = {})
223223
raise Money::Bank::UnknownRateFormat unless RATE_FORMATS.include?(format)
224224

225225
store.transaction do
@@ -259,7 +259,7 @@ def rates
259259
#
260260
# bank.get_rate("USD", "CAD") #=> 1.24515
261261
# bank.get_rate("CAD", "USD") #=> 0.803115
262-
def import_rates(format, string, opts = {})
262+
def import_rates(format, string, _opts = {})
263263
raise Money::Bank::UnknownRateFormat unless RATE_FORMATS.include?(format)
264264

265265
if format == :ruby

lib/money/currency/heuristics.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Money
44
class Currency
55
module Heuristics
6-
def analyze(str)
6+
def analyze(_str)
77
raise StandardError, 'Heuristics deprecated, add `gem "money-heuristics"` to Gemfile'
88
end
99
end

lib/money/locale_backend/i18n.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class I18n < Base
1414

1515
def initialize
1616
raise NotSupported, 'I18n not found' unless defined?(::I18n)
17+
18+
super
1719
end
1820

1921
def lookup(key, _)

lib/money/money.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ def self.setup_defaults
242242

243243
def self.inherited(base)
244244
base.setup_defaults
245+
246+
super
245247
end
246248

247249
setup_defaults

lib/money/money/arithmetic.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def <=>(other)
7777
other = other.exchange_to(currency)
7878
fractional <=> other.fractional
7979
rescue Money::Bank::UnknownRate
80+
nil
8081
end
8182

8283
# Uses Comparable's implementation but raises ArgumentError if non-zero

lib/money/money/formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def append_sign(formatted_number)
262262
.gsub('%u', [sign_before, symbol_value].join)
263263
.gsub('%n', [sign, formatted_number].join)
264264
else
265-
formatted_number = "#{sign_before}#{sign}#{formatted_number}"
265+
"#{sign_before}#{sign}#{formatted_number}"
266266
end
267267
end
268268

spec/money/arithmetic_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@
5656
expect(Money.new(1, "USD")).not_to eq 0
5757
end
5858

59+
# rubocop:disable Lint/FloatComparison
5960
it 'raises error for non-zero numerics' do
6061
expect { Money.new(1_00, "USD") == 1 }.to raise_error ArgumentError
6162
expect { Money.new(1_00, "USD") == -2.0 }.to raise_error ArgumentError
6263
expect { Money.new(1_00, "USD") == Float::INFINITY }.to raise_error ArgumentError
6364
end
65+
# rubocop:enable Lint/FloatComparison
6466
end
6567

6668
describe "#eql?" do
@@ -110,6 +112,7 @@
110112
end
111113
end
112114

115+
# rubocop:disable Lint/FloatComparison
113116
it "returns false if used to compare with an object that doesn't inherit from Money" do
114117
expect(Money.new(1_00, "USD").eql?(Object.new)).to be false
115118
expect(Money.new(1_00, "USD").eql?(Class)).to be false
@@ -120,6 +123,7 @@
120123
expect(Money.new(1_00, "USD").eql?(1)).to be false
121124
expect(Money.new(1_00, "USD").eql?(1_00)).to be false
122125
end
126+
# rubocop:enable Lint/FloatComparison
123127

124128
it "can be used to compare with an object that inherits from Money" do
125129
klass = Class.new(Money)

spec/money/formatting_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
expect(Money.new(100, "SEK").format(symbol: true)).to eq "1,00 kr"
341341
end
342342

343-
specify "(symbol: "", nil or false) returns the amount without a symbol" do
343+
specify "(symbol: \"\", nil or false) returns the amount without a symbol" do
344344
money = Money.new(100, "GBP")
345345
expect(money.format(symbol: "")).to eq "1.00"
346346
expect(money.format(symbol: nil)).to eq "1.00"

0 commit comments

Comments
 (0)