refactor: catch doesn't need to have a param (no-changelog) (#5614)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-03-03 18:18:49 +01:00 committed by GitHub
parent 9420b0fdf8
commit 4e244937c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 59 additions and 59 deletions

View file

@ -88,7 +88,7 @@ export const executeCommand = async (
try { try {
await fsAccess(downloadFolder); await fsAccess(downloadFolder);
} catch (_) { } catch {
await fsMkdir(downloadFolder); await fsMkdir(downloadFolder);
// Also init the folder since some versions // Also init the folder since some versions
// of npm complain if the folder is empty // of npm complain if the folder is empty
@ -154,7 +154,7 @@ export function matchMissingPackages(
return parsedPackageData.packageName; return parsedPackageData.packageName;
// eslint-disable-next-line no-empty // eslint-disable-next-line no-empty
} catch (_) {} } catch {}
return undefined; return undefined;
}); });

View file

@ -125,7 +125,7 @@ const isJsonRequest = (curlJson: CurlJson): boolean => {
try { try {
JSON.parse(bodyKey); JSON.parse(bodyKey);
return true; return true;
} catch (_) { } catch {
return false; return false;
} }
} }

View file

@ -217,7 +217,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
const removeCommand = `npm remove ${packageName}`; const removeCommand = `npm remove ${packageName}`;
try { try {
await executeCommand(removeCommand); await executeCommand(removeCommand);
} catch (_) {} } catch {}
throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES); throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES);
} }
@ -284,7 +284,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
const removeCommand = `npm remove ${packageName}`; const removeCommand = `npm remove ${packageName}`;
try { try {
await executeCommand(removeCommand); await executeCommand(removeCommand);
} catch (_) {} } catch {}
throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES); throw new Error(RESPONSE_ERROR_MESSAGES.PACKAGE_DOES_NOT_CONTAIN_NODES);
} }
} }
@ -418,7 +418,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
await fsAccess(checkPath); await fsAccess(checkPath);
// Folder exists, so use it. // Folder exists, so use it.
return path.dirname(checkPath); return path.dirname(checkPath);
} catch (_) {} // Folder does not exist so get next one } catch {} // Folder does not exist so get next one
} }
throw new Error('Could not find "node_modules" folder!'); throw new Error('Could not find "node_modules" folder!');
} }

View file

@ -16,7 +16,7 @@ export const validCredentialType = (
): express.Response | void => { ): express.Response | void => {
try { try {
Container.get(CredentialTypes).getByName(req.body.type); Container.get(CredentialTypes).getByName(req.body.type);
} catch (_) { } catch {
return res.status(400).json({ message: 'req.body.type is not a known type' }); return res.status(400).json({ message: 'req.body.type is not a known type' });
} }

View file

@ -202,7 +202,7 @@ nodesController.get(
if (missingPackages) { if (missingPackages) {
hydratedPackages = matchMissingPackages(hydratedPackages, missingPackages); hydratedPackages = matchMissingPackages(hydratedPackages, missingPackages);
} }
} catch (_) { } catch {
// Do nothing if setting is missing // Do nothing if setting is missing
} }

View file

@ -44,7 +44,7 @@ export class TranslationController {
async getNodeTranslationHeaders() { async getNodeTranslationHeaders() {
try { try {
await access(`${NODE_HEADERS_PATH}.js`); await access(`${NODE_HEADERS_PATH}.js`);
} catch (_) { } catch {
return; // no headers available return; // no headers available
} }

View file

@ -69,7 +69,7 @@ function makeUpdateParams(fetchedWorkflows: PinData.FetchedWorkflow[]) {
if (typeof rawPinData === 'string') { if (typeof rawPinData === 'string') {
try { try {
pinDataPerWorkflow = JSON.parse(rawPinData); pinDataPerWorkflow = JSON.parse(rawPinData);
} catch (_) { } catch {
pinDataPerWorkflow = {}; pinDataPerWorkflow = {};
} }
} else { } else {

View file

@ -132,7 +132,7 @@ export class MessageEventBusDestinationWebhook
let encryptionKey: string | undefined; let encryptionKey: string | undefined;
try { try {
encryptionKey = await UserSettings.getEncryptionKey(); encryptionKey = await UserSettings.getEncryptionKey();
} catch (_) {} } catch {}
if (encryptionKey) { if (encryptionKey) {
this.credentialsHelper = new CredentialsHelper(encryptionKey); this.credentialsHelper = new CredentialsHelper(encryptionKey);
} }
@ -189,7 +189,7 @@ export class MessageEventBusDestinationWebhook
// query is specified using JSON // query is specified using JSON
try { try {
JSON.parse(this.jsonQuery); JSON.parse(this.jsonQuery);
} catch (_) { } catch {
console.log('JSON parameter need to be an valid JSON'); console.log('JSON parameter need to be an valid JSON');
} }
this.axiosRequestOptions.params = jsonParse(this.jsonQuery); this.axiosRequestOptions.params = jsonParse(this.jsonQuery);
@ -207,7 +207,7 @@ export class MessageEventBusDestinationWebhook
// body is specified using JSON // body is specified using JSON
try { try {
JSON.parse(this.jsonHeaders); JSON.parse(this.jsonHeaders);
} catch (_) { } catch {
console.log('JSON parameter need to be an valid JSON'); console.log('JSON parameter need to be an valid JSON');
} }
this.axiosRequestOptions.headers = jsonParse(this.jsonHeaders); this.axiosRequestOptions.headers = jsonParse(this.jsonHeaders);
@ -302,27 +302,27 @@ export class MessageEventBusDestinationWebhook
if (this.genericAuthType === 'httpBasicAuth') { if (this.genericAuthType === 'httpBasicAuth') {
try { try {
httpBasicAuth = await this.matchDecryptedCredentialType('httpBasicAuth'); httpBasicAuth = await this.matchDecryptedCredentialType('httpBasicAuth');
} catch (_) {} } catch {}
} else if (this.genericAuthType === 'httpDigestAuth') { } else if (this.genericAuthType === 'httpDigestAuth') {
try { try {
httpDigestAuth = await this.matchDecryptedCredentialType('httpDigestAuth'); httpDigestAuth = await this.matchDecryptedCredentialType('httpDigestAuth');
} catch (_) {} } catch {}
} else if (this.genericAuthType === 'httpHeaderAuth') { } else if (this.genericAuthType === 'httpHeaderAuth') {
try { try {
httpHeaderAuth = await this.matchDecryptedCredentialType('httpHeaderAuth'); httpHeaderAuth = await this.matchDecryptedCredentialType('httpHeaderAuth');
} catch (_) {} } catch {}
} else if (this.genericAuthType === 'httpQueryAuth') { } else if (this.genericAuthType === 'httpQueryAuth') {
try { try {
httpQueryAuth = await this.matchDecryptedCredentialType('httpQueryAuth'); httpQueryAuth = await this.matchDecryptedCredentialType('httpQueryAuth');
} catch (_) {} } catch {}
} else if (this.genericAuthType === 'oAuth1Api') { } else if (this.genericAuthType === 'oAuth1Api') {
try { try {
oAuth1Api = await this.matchDecryptedCredentialType('oAuth1Api'); oAuth1Api = await this.matchDecryptedCredentialType('oAuth1Api');
} catch (_) {} } catch {}
} else if (this.genericAuthType === 'oAuth2Api') { } else if (this.genericAuthType === 'oAuth2Api') {
try { try {
oAuth2Api = await this.matchDecryptedCredentialType('oAuth2Api'); oAuth2Api = await this.matchDecryptedCredentialType('oAuth2Api');
} catch (_) {} } catch {}
} }
} }

View file

@ -233,7 +233,7 @@ export abstract class DirectoryLoader {
} }
node.description.codex = codex; node.description.codex = codex;
} catch (_) { } catch {
Logger.debug(`No codex available for: ${filePath.split('/').pop() ?? ''}`); Logger.debug(`No codex available for: ${filePath.split('/').pop() ?? ''}`);
if (isCustom) { if (isCustom) {

View file

@ -129,7 +129,7 @@ export default mixins(linterExtension, completerExtension, workflowHelpers).exte
context, context,
inserted_text: insertedText, inserted_text: insertedText,
}); });
} catch (_) {} } catch {}
}, },
}, },
destroyed() { destroyed() {

View file

@ -84,7 +84,7 @@ export const completerExtension = mixins(
try { try {
variablesToValues = this.variablesToValues(); variablesToValues = this.variablesToValues();
} catch (_) { } catch {
return null; return null;
} }

View file

@ -220,7 +220,7 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({
return input.main[0][0].node; return input.main[0][0].node;
} }
} catch (_) { } catch {
return null; return null;
} }
}, },
@ -291,7 +291,7 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({
} }
return nodePinData[itemIndex].json; return nodePinData[itemIndex].json;
} catch (_) {} } catch {}
} }
const runData: IRunData | null = this.workflowsStore.getWorkflowRunData; const runData: IRunData | null = this.workflowsStore.getWorkflowRunData;
@ -309,7 +309,7 @@ export const jsonFieldCompletions = (Vue as CodeNodeEditorMixin).extend({
} }
return nodeRunData[0].data!.main[0]![itemIndex].json; return nodeRunData[0].data!.main[0]![itemIndex].json;
} catch (_) { } catch {
return null; return null;
} }
}, },

View file

@ -35,7 +35,7 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({
// optional chaining operators currently unsupported by esprima-next // optional chaining operators currently unsupported by esprima-next
if (['?.', ']?'].some((operator) => lineAtError.includes(operator))) return []; if (['?.', ']?'].some((operator) => lineAtError.includes(operator))) return [];
} catch (_) { } catch {
return []; return [];
} }
@ -50,7 +50,7 @@ export const linterExtension = (Vue as CodeNodeEditorMixin).extend({
message: this.$locale.baseText('codeNodeEditor.linter.bothModes.syntaxError'), message: this.$locale.baseText('codeNodeEditor.linter.bothModes.syntaxError'),
}, },
]; ];
} catch (_) { } catch {
/** /**
* For invalid (e.g. half-written) n8n syntax, esprima errors with an off-by-one line number for the final line. In future, we should add full linting for n8n syntax before parsing JS. * For invalid (e.g. half-written) n8n syntax, esprima errors with an off-by-one line number for the final line. In future, we should add full linting for n8n syntax before parsing JS.
*/ */

View file

@ -484,7 +484,7 @@ export default mixins(externalHooks, nodeHelpers).extend({
}); });
this.uiStore.setHttpNodeParameters({ name: IMPORT_CURL_MODAL_KEY, parameters: '' }); this.uiStore.setHttpNodeParameters({ name: IMPORT_CURL_MODAL_KEY, parameters: '' });
} catch (_) {} } catch {}
} }
}, },
}, },

View file

@ -32,7 +32,7 @@ export function bracketAccessCompletions(context: CompletionContext): Completion
try { try {
resolved = resolveParameter(`={{ ${base} }}`); resolved = resolveParameter(`={{ ${base} }}`);
} catch (_) { } catch {
return null; return null;
} }

View file

@ -44,7 +44,7 @@ export function datatypeCompletions(context: CompletionContext): CompletionResul
try { try {
resolved = resolveParameter(`={{ ${base} }}`); resolved = resolveParameter(`={{ ${base} }}`);
} catch (_) { } catch {
return null; return null;
} }
@ -52,7 +52,7 @@ export function datatypeCompletions(context: CompletionContext): CompletionResul
try { try {
options = datatypeOptions(resolved, base).map(stripExcessParens(context)); options = datatypeOptions(resolved, base).map(stripExcessParens(context));
} catch (_) { } catch {
return null; return null;
} }
} }

View file

@ -611,22 +611,22 @@ export class HttpRequestV1 implements INodeType {
try { try {
httpBasicAuth = await this.getCredentials('httpBasicAuth'); httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch (_) {} } catch {}
try { try {
httpDigestAuth = await this.getCredentials('httpDigestAuth'); httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch (_) {} } catch {}
try { try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth'); httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch (_) {} } catch {}
try { try {
httpQueryAuth = await this.getCredentials('httpQueryAuth'); httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch (_) {} } catch {}
try { try {
oAuth1Api = await this.getCredentials('oAuth1Api'); oAuth1Api = await this.getCredentials('oAuth1Api');
} catch (_) {} } catch {}
try { try {
oAuth2Api = await this.getCredentials('oAuth2Api'); oAuth2Api = await this.getCredentials('oAuth2Api');
} catch (_) {} } catch {}
let requestOptions: OptionsWithUri; let requestOptions: OptionsWithUri;
let setUiParameter: IDataObject; let setUiParameter: IDataObject;

View file

@ -621,7 +621,7 @@ export class HttpRequestV2 implements INodeType {
| 'predefinedCredentialType' | 'predefinedCredentialType'
| 'genericCredentialType' | 'genericCredentialType'
| 'none'; | 'none';
} catch (_) {} } catch {}
let httpBasicAuth; let httpBasicAuth;
let httpDigestAuth; let httpDigestAuth;
@ -637,32 +637,32 @@ export class HttpRequestV2 implements INodeType {
if (genericAuthType === 'httpBasicAuth') { if (genericAuthType === 'httpBasicAuth') {
try { try {
httpBasicAuth = await this.getCredentials('httpBasicAuth'); httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'httpDigestAuth') { } else if (genericAuthType === 'httpDigestAuth') {
try { try {
httpDigestAuth = await this.getCredentials('httpDigestAuth'); httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'httpHeaderAuth') { } else if (genericAuthType === 'httpHeaderAuth') {
try { try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth'); httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'httpQueryAuth') { } else if (genericAuthType === 'httpQueryAuth') {
try { try {
httpQueryAuth = await this.getCredentials('httpQueryAuth'); httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'oAuth1Api') { } else if (genericAuthType === 'oAuth1Api') {
try { try {
oAuth1Api = await this.getCredentials('oAuth1Api'); oAuth1Api = await this.getCredentials('oAuth1Api');
} catch (_) {} } catch {}
} else if (genericAuthType === 'oAuth2Api') { } else if (genericAuthType === 'oAuth2Api') {
try { try {
oAuth2Api = await this.getCredentials('oAuth2Api'); oAuth2Api = await this.getCredentials('oAuth2Api');
} catch (_) {} } catch {}
} }
} else if (authentication === 'predefinedCredentialType') { } else if (authentication === 'predefinedCredentialType') {
try { try {
nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string; nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string;
} catch (_) {} } catch {}
} }
let requestOptions: OptionsWithUri; let requestOptions: OptionsWithUri;

View file

@ -888,7 +888,7 @@ export class HttpRequestV3 implements INodeType {
| 'predefinedCredentialType' | 'predefinedCredentialType'
| 'genericCredentialType' | 'genericCredentialType'
| 'none'; | 'none';
} catch (_) {} } catch {}
let httpBasicAuth; let httpBasicAuth;
let httpDigestAuth; let httpDigestAuth;
@ -904,32 +904,32 @@ export class HttpRequestV3 implements INodeType {
if (genericAuthType === 'httpBasicAuth') { if (genericAuthType === 'httpBasicAuth') {
try { try {
httpBasicAuth = await this.getCredentials('httpBasicAuth'); httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'httpDigestAuth') { } else if (genericAuthType === 'httpDigestAuth') {
try { try {
httpDigestAuth = await this.getCredentials('httpDigestAuth'); httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'httpHeaderAuth') { } else if (genericAuthType === 'httpHeaderAuth') {
try { try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth'); httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'httpQueryAuth') { } else if (genericAuthType === 'httpQueryAuth') {
try { try {
httpQueryAuth = await this.getCredentials('httpQueryAuth'); httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch (_) {} } catch {}
} else if (genericAuthType === 'oAuth1Api') { } else if (genericAuthType === 'oAuth1Api') {
try { try {
oAuth1Api = await this.getCredentials('oAuth1Api'); oAuth1Api = await this.getCredentials('oAuth1Api');
} catch (_) {} } catch {}
} else if (genericAuthType === 'oAuth2Api') { } else if (genericAuthType === 'oAuth2Api') {
try { try {
oAuth2Api = await this.getCredentials('oAuth2Api'); oAuth2Api = await this.getCredentials('oAuth2Api');
} catch (_) {} } catch {}
} }
} else if (authentication === 'predefinedCredentialType') { } else if (authentication === 'predefinedCredentialType') {
try { try {
nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string; nodeCredentialType = this.getNodeParameter('nodeCredentialType', 0) as string;
} catch (_) {} } catch {}
} }
let requestOptions: OptionsWithUri = { let requestOptions: OptionsWithUri = {
@ -1110,7 +1110,7 @@ export class HttpRequestV3 implements INodeType {
if (typeof jsonBodyParameter !== 'object' && jsonBodyParameter !== null) { if (typeof jsonBodyParameter !== 'object' && jsonBodyParameter !== null) {
try { try {
JSON.parse(jsonBodyParameter); JSON.parse(jsonBodyParameter);
} catch (_) { } catch {
throw new NodeOperationError( throw new NodeOperationError(
this.getNode(), this.getNode(),
'JSON parameter need to be an valid JSON', 'JSON parameter need to be an valid JSON',
@ -1163,7 +1163,7 @@ export class HttpRequestV3 implements INodeType {
// query is specified using JSON // query is specified using JSON
try { try {
JSON.parse(jsonQueryParameter); JSON.parse(jsonQueryParameter);
} catch (_) { } catch {
throw new NodeOperationError( throw new NodeOperationError(
this.getNode(), this.getNode(),
'JSON parameter need to be an valid JSON', 'JSON parameter need to be an valid JSON',
@ -1188,7 +1188,7 @@ export class HttpRequestV3 implements INodeType {
// body is specified using JSON // body is specified using JSON
try { try {
JSON.parse(jsonHeadersParameter); JSON.parse(jsonHeadersParameter);
} catch (_) { } catch {
throw new NodeOperationError( throw new NodeOperationError(
this.getNode(), this.getNode(),
'JSON parameter need to be an valid JSON', 'JSON parameter need to be an valid JSON',

View file

@ -64,7 +64,7 @@ export function getDomainBase(raw: string, urlParts = URL_PARTS_REGEX): string {
const url = new URL(raw); const url = new URL(raw);
return [url.protocol, url.hostname].join('//'); return [url.protocol, url.hostname].join('//');
} catch (_) { } catch {
const match = urlParts.exec(raw); const match = urlParts.exec(raw);
if (!match?.groups?.protocolPlusDomain) return ''; if (!match?.groups?.protocolPlusDomain) return '';
@ -98,7 +98,7 @@ export function getDomainPath(raw: string, urlParts = URL_PARTS_REGEX): string {
if (!url.hostname) throw new Error('Malformed URL'); if (!url.hostname) throw new Error('Malformed URL');
return sanitizeRoute(url.pathname); return sanitizeRoute(url.pathname);
} catch (_) { } catch {
const match = urlParts.exec(raw); const match = urlParts.exec(raw);
if (!match?.groups?.pathname) return ''; if (!match?.groups?.pathname) return '';
@ -168,7 +168,7 @@ export function generateNodesGraph(
if (node.type === 'n8n-nodes-base.httpRequest' && node.typeVersion === 1) { if (node.type === 'n8n-nodes-base.httpRequest' && node.typeVersion === 1) {
try { try {
nodeItem.domain = new URL(node.parameters.url as string).hostname; nodeItem.domain = new URL(node.parameters.url as string).hostname;
} catch (_) { } catch {
nodeItem.domain = getDomainBase(node.parameters.url as string); nodeItem.domain = getDomainBase(node.parameters.url as string);
} }
} else if (node.type === 'n8n-nodes-base.httpRequest' && [2, 3].includes(node.typeVersion)) { } else if (node.type === 'n8n-nodes-base.httpRequest' && [2, 3].includes(node.typeVersion)) {