Showing 6 of 28 total issues
Function emitAndWait
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async emitAndWait(eventName: string, payload: IEventPayload, replyToName?: string, options?: IEmitAndWaitOptions): Promise<IEventPayload> {
return new Promise(async (resolve, reject) => {
LOGGER.info(`Emitting ${eventName} Message and waiting ...`);
LOGGER.debug(`Event ${eventName}, payload received`, { payload, replyToName });
let replyTo = replyToName ? replyToName : `${eventName}${this.options.defaultResponseSuffix}`;
Function consume
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function consume(channel: amqp.Channel, queueName: string, listener: ConsumeHandlerFunction, options: IEventManagerOptions): Promise<IEventPayload | void | null> {
LOGGER.info(`Consume messages of queue ${queueName}`);
return new Promise((resolve, reject) => {
try {
channel.consume(queueName, message => {
Function on
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async on(eventName: string, listener: EventHandlerFunction, options?: IListenerOption) {
try {
LOGGER.debug(`Listening ${eventName} Event ...`);
const channel = await adapter.createChannel(this.options.url);
const queueName = `${this.options.application}::${eventName}`;
Consider simplifying this complex logical expression. Open
Open
if (
sourcePayload &&
sourcePayload._metas &&
sourcePayload._metas.correlationId &&
sourcePayload._metas.replyTo &&
Function on
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public async on(eventName: string, listener: EventHandlerFunction, options?: IListenerOption) {
try {
LOGGER.debug(`Listening ${eventName} Event ...`);
const channel = await adapter.createChannel(this.options.url);
const queueName = `${this.options.application}::${eventName}`;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function addMetasToPayload
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
private addMetasToPayload(payload: IEventPayload, eventName: string): IEventPayload {
if (!this.options.metas) {
return payload;
} else {
const metasOverride = payload._metas ? payload._metas : {};
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"