Skip to content

Commit 1bc622a

Browse files
xDivisionByZeroxLeyla Jähnig
and
Leyla Jähnig
authored
fix: remove unreachable code finance (#508)
Co-authored-by: Leyla Jähnig <[email protected]>
1 parent 9ab0825 commit 1bc622a

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

src/finance.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -258,32 +258,17 @@ export class Finance {
258258
*/
259259
creditCardNumber(provider = ''): string {
260260
let format: string;
261-
let formats: string | string[];
262261
const localeFormat = this.faker.definitions.finance.credit_card;
263262
if (provider in localeFormat) {
264-
formats = localeFormat[provider]; // there could be multiple formats
265-
if (typeof formats === 'string') {
266-
format = formats;
267-
} else {
268-
format = this.faker.random.arrayElement(formats);
269-
}
263+
format = this.faker.random.arrayElement(localeFormat[provider]);
270264
} else if (provider.match(/#/)) {
271265
// The user chose an optional scheme
272266
format = provider;
273267
} else {
274268
// Choose a random provider
275-
// TODO ST-DDT 2022-01-30: #375 This is impossible to access
276-
if (typeof localeFormat === 'string') {
277-
format = localeFormat;
278-
} else if (typeof localeFormat === 'object') {
279-
// Credit cards are in a object structure
280-
formats = this.faker.random.objectElement(localeFormat, 'value'); // There could be multiple formats
281-
if (typeof formats === 'string') {
282-
format = formats;
283-
} else {
284-
format = this.faker.random.arrayElement(formats);
285-
}
286-
}
269+
// Credit cards are in an object structure
270+
const formats = this.faker.random.objectElement(localeFormat, 'value'); // There could be multiple formats
271+
format = this.faker.random.arrayElement(formats);
287272
}
288273
format = format.replace(/\//g, '');
289274
return this.Helpers.replaceCreditCardSymbols(format);

0 commit comments

Comments
 (0)