Skip to content

Commit

Permalink
Fix 'Unused method receiver RVV-B0013'
Browse files Browse the repository at this point in the history
  • Loading branch information
antfroger committed Apr 23, 2024
1 parent 3a9523c commit fdc4268
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions iban.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (p Payment) ibanForCountry(countryCode string) string {
}

bban := strings.ToUpper(p.bban(format))
checksum := p.ibanChecksum(countryCode + "00" + bban)
checksum := ibanChecksum(countryCode + "00" + bban)

return countryCode + checksum + bban
}
Expand All @@ -125,7 +125,11 @@ func (p Payment) bban(format string) string {
return p.Faker.Bothify(format)
}

func (p Payment) ibanChecksum(iban string) string {
func (p Payment) isIbanValid(iban string) bool {
return ibanChecksum(iban) == iban[2:4]
}

func ibanChecksum(iban string) string {
iban = strings.ToUpper(strings.ReplaceAll(iban, " ", ""))

// Move first 4 characters to the end, and set checksum to 00
Expand Down Expand Up @@ -155,7 +159,3 @@ func (p Payment) ibanChecksum(iban string) string {
}
return fmt.Sprintf("%d", checksum)
}

func (p Payment) isIbanValid(iban string) bool {
return p.ibanChecksum(iban) == iban[2:4]
}
3 changes: 1 addition & 2 deletions iban_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,8 @@ func TestIbanChecksum(t *testing.T) {
"ZZ00VLQT382332233206588011313776421": "25",
}

p := New().Payment()
for iban, checksum := range ibans {
Expect(t, checksum, p.ibanChecksum(iban))
Expect(t, checksum, ibanChecksum(iban))
}
}

Expand Down

0 comments on commit fdc4268

Please sign in to comment.