mimiz/rabbitmq-event-manager

View on GitHub
src/EventManager.class.ts

Summary

Maintainability
B
5 hrs
Test Coverage

Function emitAndWait has 51 lines of code (exceeds 25 allowed). Consider refactoring.
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}`;
Severity: Major
Found in src/EventManager.class.ts - About 2 hrs to fix

    Function on has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    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}`;
    Severity: Minor
    Found in src/EventManager.class.ts - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if (
            sourcePayload &&
            sourcePayload._metas &&
            sourcePayload._metas.correlationId &&
            sourcePayload._metas.replyTo &&
      Severity: Major
      Found in src/EventManager.class.ts - About 40 mins to fix

        Function on has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        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}`;
        Severity: Minor
        Found in src/EventManager.class.ts - About 35 mins to fix

        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

          private addMetasToPayload(payload: IEventPayload, eventName: string): IEventPayload {
            if (!this.options.metas) {
              return payload;
            } else {
              const metasOverride = payload._metas ? payload._metas : {};
        Severity: Minor
        Found in src/EventManager.class.ts - About 35 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status