Skip to content

Commit 633d6a4

Browse files
committed
fix: linting
1 parent 486a3ef commit 633d6a4

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

lib/valvat/checksum/ch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class CH < Base
66
# All CH VAT starts with CHE. First figure is a character and should be skipped.
77
# The CH VATs can have a suffix (MWST, TVA, IVA) which should be skipped.
88
# Thus giving 8 figures to calculate the check digit
9-
FIGURES_RANGE = [1..8]
9+
FIGURES_RANGE = [1..8].freeze
1010
CHECK_DIGIT_POS = 9
1111

1212
def check_digit

lib/valvat/lookup/bfs.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BFS < Base
3535
def self.prepare_for_lookup(vat)
3636
# BFS requires a space between the VAT number and the suffix (if present)
3737
index_of_suffix = vat =~ /MWST|IVA|TVA/
38-
return if !index_of_suffix
38+
return unless index_of_suffix
3939

4040
vat.insert(index_of_suffix, ' ')
4141
end
@@ -90,18 +90,17 @@ def convert_values(hash)
9090
return build_fault(hash) if hash[:faultstring]
9191

9292
is_valid = case hash[:validate_vat_number_result]
93-
when 'true' then true
94-
when 'false' then false
95-
else nil
96-
end
93+
when 'true' then true
94+
when 'false' then false
95+
end
9796

9897
{ valid: is_valid }
9998
end
10099

101100
FAULTS = {
102101
'securityFaultFault' => SecurityError,
103102
'businessFaultFault' => BusinessError,
104-
'infrastructureFaultFault' => InfrastructureError,
103+
'infrastructureFaultFault' => InfrastructureError
105104
}.freeze
106105

107106
def build_fault(hash)

spec/valvat/checksum/ch_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
require 'spec_helper'
44

55
describe Valvat::Checksum::CH do
6-
["CHE-343.663.860", "CHE343663860", "CHE-355.036.078", "CHE355036078", "CHE-480.519.647", " CHE480519647"].each do |valid_vat|
6+
['CHE-343.663.860', 'CHE343663860', 'CHE-355.036.078', 'CHE355036078', 'CHE-480.519.647',
7+
"\tCHE480519647"].each do |valid_vat|
78
it "returns true on valid VAT #{valid_vat}" do
89
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
910
end

spec/valvat/lookup/bfs_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
it 'returns hash that includes valid: false on invalid input' do
1313
response = described_class.new('CHE-343.663.86MWST', ch: true).perform
1414
expect(response).to match({
15-
:detail=>nil,
16-
:faultcode=>"s:Client",
17-
:faultstring=>"Data_validation_failed",
18-
:valid=>false,
15+
detail: nil,
16+
faultcode: 's:Client',
17+
faultstring: 'Data_validation_failed',
18+
valid: false
1919
})
2020
end
2121
end

spec/valvat/syntax_spec.rb

+9-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ def it_validates(valid_vats, invalid_vats)
2121
it_validates(%w[ATU03458890], %w[ATU034588908 ATU0345908 ATU0345889Y])
2222
it_validates(%w[BE0817331995 BE1817331999], %w[BE081733199 BE08173319944 BE081733199H BE2817331999])
2323
it_validates(%w[BG468134789 BG4681347897], %w[BG46813478979 BG4681347897C BG46813478G BG46813478])
24-
it_validates(["CHE-343.663.860", "CHE-343.663.860MWST", "CHE-343.663.860 MWST", "CHE343663860", "CHE343663860MWST", "CHE343663860 MWST"],
25-
["CHE-343.663.8601", "CHE-343.663.8601MWST", "CHE-343.663.8601 MWST", "CHE-34.663.860", "CHE-34.663.860MWST", "CHE-34.663.860 MWST"])
26-
it_validates(["CHE-343.663.860", "CHE-343.663.860TVA", "CHE-343.663.860 TVA", "CHE343663860", "CHE343663860TVA", "CHE343663860 TVA"],
27-
["CHE-343.663.8601", "CHE-343.663.8601TVA", "CHE-343.663.8601 TVA", "CHE-34.663.860", "CHE-34.663.860TVA", "CHE-34.663.860 TVA"])
28-
it_validates(["CHE-343.663.860", "CHE-343.663.860IVA", "CHE-343.663.860 IVA", "CHE343663860", "CHE343663860IVA", "CHE343663860 IVA"],
29-
["CHE-343.663.8601", "CHE-343.663.8601IVA", "CHE-343.663.8601 IVA", "CHE-34.663.860", "CHE-34.663.860IVA", "CHE-34.663.860 IVA"])
24+
it_validates(['CHE-343.663.860', 'CHE-343.663.860MWST', 'CHE-343.663.860 MWST', 'CHE343663860', 'CHE343663860MWST', 'CHE343663860 MWST'],
25+
['CHE-343.663.8601', 'CHE-343.663.8601MWST', 'CHE-343.663.8601 MWST', 'CHE-34.663.860',
26+
'CHE-34.663.860MWST', 'CHE-34.663.860 MWST'])
27+
it_validates(['CHE-343.663.860', 'CHE-343.663.860TVA', 'CHE-343.663.860 TVA', 'CHE343663860', 'CHE343663860TVA', 'CHE343663860 TVA'],
28+
['CHE-343.663.8601', 'CHE-343.663.8601TVA', 'CHE-343.663.8601 TVA', 'CHE-34.663.860',
29+
'CHE-34.663.860TVA', 'CHE-34.663.860 TVA'])
30+
it_validates(['CHE-343.663.860', 'CHE-343.663.860IVA', 'CHE-343.663.860 IVA', 'CHE343663860', 'CHE343663860IVA', 'CHE343663860 IVA'],
31+
['CHE-343.663.8601', 'CHE-343.663.8601IVA', 'CHE-343.663.8601 IVA', 'CHE-34.663.860',
32+
'CHE-34.663.860IVA', 'CHE-34.663.860 IVA'])
3033
it_validates(%w[CY36579347A CY36579347C CY60000347C], %w[CY36579347 CY365793478 CY365793478A CY365793G])
3134
it_validates(%w[CZ56389267 CZ563892670 CZ5638926790], %w[CZ5638926 CZ56389268901])
3235
it_validates(%w[DE345889003], %w[DE34588900 DE3458890090 DE34588900C])

0 commit comments

Comments
 (0)