Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Straighten the method with guard clauses #169

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions lib/commons/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@
};

const getApiKey = ({ apiKey, token }) => {
let calculatedApiKey = apiKey;
if (!calculatedApiKey) {
calculatedApiKey = token;
if (!calculatedApiKey) {
throw new ReportPortalRequiredOptionError('apiKey');
} else {
console.warn(`Option 'token' is deprecated. Use 'apiKey' instead.`);
}
}

return calculatedApiKey;
if (apiKey) return apiKey;

Check failure on line 21 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (16)

Delete `··`

Check failure on line 21 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (18)

Delete `··`

Check failure on line 21 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (20)

Delete `··`
if (!token) throw new ReportPortalRequiredOptionError('apiKey');
console.warn(`Option 'token' is deprecated. Use 'apiKey' instead.`);

Check warning on line 23 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 23 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 23 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement
return token;
};

const getClientConfig = (options) => {
Expand Down Expand Up @@ -68,7 +61,7 @@
};
} catch (error) {
// don't throw the error up to not break the entire process
console.dir(error);

Check warning on line 64 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 64 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 64 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement
}

return calculatedOptions;
Expand Down
Loading