Skip to content

Commit 27850e2

Browse files
authored
Lint: Fix trailing commas (#1179)
1 parent 3309010 commit 27850e2

File tree

12 files changed

+55
-45
lines changed

12 files changed

+55
-45
lines changed

.rubocop.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,30 @@ Style/SymbolArray:
9191
# Prefer [:a, :b] to %i[a b]
9292
EnforcedStyle: brackets
9393

94+
Style/TrailingCommaInArguments:
95+
# Prefer trailing commas in multiline arguments:
96+
# call(
97+
# a: 1,
98+
# b: 2,
99+
# )
100+
EnforcedStyleForMultiline: diff_comma
101+
102+
Style/TrailingCommaInArrayLiteral:
103+
# Prefer trailing commas in arrays:
104+
# [
105+
# 1,
106+
# 2,
107+
# ]
108+
EnforcedStyleForMultiline: diff_comma
109+
110+
Style/TrailingCommaInHashLiteral:
111+
# Prefer trailing commas in multiline hashes:
112+
# {
113+
# a: 1,
114+
# b: 2,
115+
# }
116+
EnforcedStyleForMultiline: diff_comma
117+
94118
Style/YodaCondition:
95119
# Sometimes in specs it makes more sense to write
96120
# 2 >= Money.new(2, 'USD')

.rubocop_todo.yml

Lines changed: 0 additions & 14 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def exchange_with(from, to_currency, &block)
118118
from.dup_with(
119119
fractional: exchange(fractional, rate, &block),
120120
currency: to_currency,
121-
bank: self
121+
bank: self,
122122
)
123123
else
124124
raise UnknownRate, "No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'"

lib/money/money.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def dup_with(options = {})
636636
self.class.new(
637637
options[:fractional] || fractional,
638638
options[:currency] || currency,
639-
bank: options[:bank] || bank
639+
bank: options[:bank] || bank,
640640
)
641641
end
642642

lib/money/money/formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Money
66
class Formatter
77
DEFAULTS = {
88
thousands_separator: '',
9-
decimal_mark: '.'
9+
decimal_mark: '.',
1010
}.freeze
1111

1212
# Creates a formatted price string according to several rules.
@@ -230,7 +230,7 @@ def format_number
230230
[
231231
html_wrap(whole_part, "whole"),
232232
html_wrap(decimal_mark, "decimal-mark"),
233-
html_wrap(decimal_part, "decimal")
233+
html_wrap(decimal_part, "decimal"),
234234
].join
235235
end
236236
else

lib/money/money/locale_backend.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Money
88
module LocaleBackend
99
BACKENDS = {
1010
i18n: Money::LocaleBackend::I18n,
11-
currency: Money::LocaleBackend::Currency
11+
currency: Money::LocaleBackend::Currency,
1212
}.freeze
1313

1414
def self.find(name)

spec/currency_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def to_s
8585
subunit: "Centimes",
8686
subunit_to_unit: 100,
8787
decimal_mark: ",",
88-
thousands_separator: " "
88+
thousands_separator: " ",
8989
)
9090

9191
expect(described_class.find_by_iso_numeric(250)).to eq described_class.new(:frf)
@@ -100,7 +100,7 @@ def to_s
100100
name: "French Francs",
101101
symbol: "FR",
102102
subunit: "Centimes",
103-
subunit_to_unit: 100
103+
subunit_to_unit: 100,
104104
)
105105

106106
expect(described_class.find_by_iso_numeric(250)).to eq described_class.new(:frf)
@@ -160,7 +160,7 @@ def to_s
160160
iso_code: "XXX",
161161
name: "Golden Doubloon",
162162
symbol: "%",
163-
subunit_to_unit: 100
163+
subunit_to_unit: 100,
164164
)
165165
new_currency = described_class.find("XXX")
166166
expect(new_currency).not_to be_nil
@@ -187,12 +187,12 @@ def to_s
187187
iso_code: "XXX",
188188
name: "Golden Doubloon",
189189
symbol: "%",
190-
subunit_to_unit: 100
190+
subunit_to_unit: 100,
191191
)
192192
described_class.inherit(
193193
"XXX",
194194
iso_code: "YYY",
195-
symbol: "@"
195+
symbol: "@",
196196
)
197197
new_currency = described_class.find("YYY")
198198
expect(new_currency).not_to be_nil
@@ -481,7 +481,7 @@ def to_s
481481
:subunit => cad.subunit,
482482
:subunit_to_unit => cad.subunit_to_unit,
483483
:thousands_separator => cad.thousands_separator,
484-
:decimal_mark => modified_mark
484+
:decimal_mark => modified_mark,
485485
)
486486
end
487487

spec/locale_backend/i18n_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
before do
2121
I18n.locale = :de
2222
I18n.backend.store_translations(:de, number: {
23-
currency: { format: { delimiter: '.', separator: ',', unit: '$', format: '%u%n' } }
23+
currency: { format: { delimiter: '.', separator: ',', unit: '$', format: '%u%n' } },
2424
})
2525
end
2626

spec/money/allocation_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
expect(parts.map { |x| x.round(10) }).to eq([
5353
BigDecimal('33.3333333333'),
5454
BigDecimal('33.3333333333'),
55-
BigDecimal('33.3333333333')
55+
BigDecimal('33.3333333333'),
5656
])
5757
expect(parts.inject(0, :+)).to eq(amount)
5858
end
@@ -126,7 +126,7 @@
126126
expect(parts.map { |x| x.round(10) }).to eq([
127127
BigDecimal('33.3333333333'),
128128
BigDecimal('33.3333333333'),
129-
BigDecimal('33.3333333333')
129+
BigDecimal('33.3333333333'),
130130
])
131131
expect(parts.inject(0, :+)).to eq(amount)
132132
end
@@ -163,7 +163,7 @@
163163
90.36, 90.36, 90.36, 90.36,
164164
90.36, 90.36, 90.36, 90.36,
165165
90.36, 90.36, 90.36, 90.36,
166-
90.36
166+
90.36,
167167
]
168168
end
169169

spec/money/formatting_rules_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
it 'returns the translated format for the locale' do
2828
I18n.backend.store_translations(:fr, number: {
29-
currency: { format: { format: "%n %u" } }
29+
currency: { format: { format: "%n %u" } },
3030
})
3131
currency = Money::Currency.new('EUR')
3232
rules = { separator: '.', delimiter: ',' }
@@ -47,7 +47,7 @@
4747
it 'returns the default format for the locale' do
4848
allow(Money).to receive(:locale_backend).and_return(nil)
4949
I18n.backend.store_translations(:fr, number: {
50-
currency: { format: { format: "%n %u" } }
50+
currency: { format: { format: "%n %u" } },
5151
})
5252
currency = Money::Currency.new('EUR')
5353
rules = { separator: '.', delimiter: ',' }

0 commit comments

Comments
 (0)