refactor(core): Lint for cyclomatic complexity in BE packages (no-changelog) (#9111)

This commit is contained in:
Iván Ovejero
2024-04-10 14:02:02 +02:00
committed by GitHub
parent 9eab357b75
commit a3b59843d5
31 changed files with 40 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ module.exports = {
rules: {
'n8n-local-rules/no-dynamic-import-template': 'error',
complexity: 'error',
// TODO: Remove this
'import/no-cycle': 'warn',

View File

@@ -262,6 +262,7 @@ const mapCookies = (cookies: CurlJson['cookies']): { cookie: string } | {} => {
};
};
// eslint-disable-next-line complexity
export const toHttpNodeParameters = (curlCommand: string): HttpNodeParameters => {
const curlJson = curlToJson(curlCommand);

View File

@@ -339,6 +339,7 @@ export class InternalHooks {
]);
}
// eslint-disable-next-line complexity
async onWorkflowPostExecute(
executionId: string,
workflow: IWorkflowBase,

View File

@@ -158,6 +158,7 @@ export function toJsonSchema(properties: INodeProperties[]): IDataObject {
// object in the JSON Schema definition. This allows us
// to later validate that only this properties are set in
// the credentials sent in the API call.
// eslint-disable-next-line complexity
properties.forEach((property) => {
if (property.required) {
requiredFields.push(property.name);

View File

@@ -217,6 +217,7 @@ const normalizeFormData = <T>(values: Record<string, T | T[]>) => {
/**
* Executes a webhook
*/
// eslint-disable-next-line complexity
export async function executeWebhook(
workflow: Workflow,
webhookData: IWebhookData,
@@ -625,6 +626,7 @@ export async function executeWebhook(
executionId,
) as Promise<IExecutionDb | undefined>;
executePromise
// eslint-disable-next-line complexity
.then(async (data) => {
if (data === undefined) {
if (!didSendResponse) {

View File

@@ -166,6 +166,7 @@ export class ExecuteBatch extends BaseCommand {
await this.initExternalHooks();
}
// eslint-disable-next-line complexity
async run() {
const { flags } = await this.parse(ExecuteBatch);
ExecuteBatch.debug = flags.debug;

View File

@@ -48,6 +48,7 @@ export class ExportCredentialsCommand extends BaseCommand {
}),
};
// eslint-disable-next-line complexity
async run() {
const { flags } = await this.parse(ExportCredentialsCommand);

View File

@@ -41,6 +41,7 @@ export class ExportWorkflowsCommand extends BaseCommand {
}),
};
// eslint-disable-next-line complexity
async run() {
const { flags } = await this.parse(ExportWorkflowsCommand);

View File

@@ -72,6 +72,7 @@ export class Column {
return this;
}
// eslint-disable-next-line complexity
toOptions(driver: Driver): TableColumnOptions {
const { name, type, isNullable, isPrimary, isGenerated, length } = this;
const isMysql = 'mysql' in driver;

View File

@@ -85,6 +85,7 @@ export class MessageEventBus extends EventEmitter {
*
* Sets `isInitialized` to `true` once finished.
*/
// eslint-disable-next-line complexity
async initialize(options?: MessageEventBusInitializeOptions): Promise<void> {
if (this.isInitialized) {
return;

View File

@@ -250,6 +250,7 @@ export class MessageEventBusDestinationWebhook
return null;
}
// eslint-disable-next-line complexity
async receiveFromEventBus(emitterPayload: MessageWithCallback): Promise<boolean> {
const { msg, confirmCallback } = emitterPayload;
let sendResult = false;

View File

@@ -16,6 +16,7 @@ export class ExecutionDataRecoveryService {
private readonly executionRepository: ExecutionRepository,
) {}
// eslint-disable-next-line complexity
async recoverExecutionData(
executionId: string,
messages: EventMessageTypes[],

View File

@@ -166,6 +166,7 @@ export class CredentialsTester {
return undefined;
}
// eslint-disable-next-line complexity
async testCredentials(
user: User,
credentialType: string,

View File

@@ -11,6 +11,7 @@ import { TestWebhooks } from '@/TestWebhooks';
import { OrchestrationService } from '@/services/orchestration.service';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
// eslint-disable-next-line complexity
export async function handleCommandMessageMain(messageString: string) {
const queueModeId = config.getEnv('redis.queueModeId');
const isMainInstance = config.getEnv('generic.instanceType') === 'main';

View File

@@ -12,6 +12,7 @@ import { Logger } from '@/Logger';
import { N8N_VERSION } from '@/constants';
export function getWorkerCommandReceivedHandler(options: WorkerCommandReceivedHandlerOptions) {
// eslint-disable-next-line complexity
return async (channel: string, messageString: string) => {
if (channel === COMMAND_REDIS_CHANNEL) {
if (!messageString) return;

View File

@@ -55,6 +55,7 @@ export class WorkflowService {
: { workflows, count };
}
// eslint-disable-next-line complexity
async update(
user: User,
workflow: WorkflowEntity,

View File

@@ -95,6 +95,7 @@ export const setupTestServer = ({
license: new LicenseMocker(),
};
// eslint-disable-next-line complexity
beforeAll(async () => {
await testDb.init();