Skip to content

Commit

Permalink
fix: remove unreachable code finance (#508)
Browse files Browse the repository at this point in the history
Co-authored-by: Leyla Jähnig <leyla.jaehnig@outlook.de>
  • Loading branch information
xDivisionByZerox and Leyla Jähnig committed Mar 21, 2022
1 parent 9ab0825 commit 1bc622a
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/finance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,32 +258,17 @@ export class Finance {
*/
creditCardNumber(provider = ''): string {
let format: string;
let formats: string | string[];
const localeFormat = this.faker.definitions.finance.credit_card;
if (provider in localeFormat) {
formats = localeFormat[provider]; // there could be multiple formats
if (typeof formats === 'string') {
format = formats;
} else {
format = this.faker.random.arrayElement(formats);
}
format = this.faker.random.arrayElement(localeFormat[provider]);
} else if (provider.match(/#/)) {
// The user chose an optional scheme
format = provider;
} else {
// Choose a random provider
// TODO ST-DDT 2022-01-30: #375 This is impossible to access
if (typeof localeFormat === 'string') {
format = localeFormat;
} else if (typeof localeFormat === 'object') {
// Credit cards are in a object structure
formats = this.faker.random.objectElement(localeFormat, 'value'); // There could be multiple formats
if (typeof formats === 'string') {
format = formats;
} else {
format = this.faker.random.arrayElement(formats);
}
}
// Credit cards are in an object structure
const formats = this.faker.random.objectElement(localeFormat, 'value'); // There could be multiple formats
format = this.faker.random.arrayElement(formats);
}
format = format.replace(/\//g, '');
return this.Helpers.replaceCreditCardSymbols(format);
Expand Down

0 comments on commit 1bc622a

Please sign in to comment.