robotty/dank-twitch-irc

View on GitHub

Showing 35 of 169 total issues

Function parseIRCMessage has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

export function parseIRCMessage(messageSrc: string): IRCMessage {
  let remainder = messageSrc;

  let ircTags: IRCMessageTags;
  if (messageSrc.startsWith("@")) {
Severity: Minor
Found in lib/message/parser/irc-message.ts - About 6 hrs 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

File join-all.spec.ts has 408 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { assert } from "chai";
import * as sinon from "sinon";
import { TimeoutError } from "../await/timeout-error";
import { assertErrorChain, fakeConnection } from "../helpers.spec";
import { JoinError } from "./join";
Severity: Minor
Found in lib/operations/join-all.spec.ts - About 5 hrs to fix

    Function parseIRCMessage has 125 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function parseIRCMessage(messageSrc: string): IRCMessage {
      let remainder = messageSrc;
    
      let ircTags: IRCMessageTags;
      if (messageSrc.startsWith("@")) {
    Severity: Major
    Found in lib/message/parser/irc-message.ts - About 5 hrs to fix

      File alternate-message-modifier.spec.ts has 329 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { assert } from "chai";
      import "mocha";
      import { promisify } from "util";
      import { fakeClient } from "../helpers.spec";
      import {
      Severity: Minor
      Found in lib/mixins/alternate-message-modifier.spec.ts - About 3 hrs to fix

        ChatClient has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class ChatClient extends BaseClient {
          public get wantedChannels(): Set<string> {
            return unionSets(this.connections.map((c) => c.wantedChannels));
          }
        
        
        Severity: Minor
        Found in lib/client/client.ts - About 2 hrs to fix

          File irc-message.spec.ts has 267 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { assert } from "chai";
          import { assertThrowsChain } from "../../helpers.spec";
          import { IRCMessage } from "../irc/irc-message";
          import { parseIRCMessage } from "./irc-message";
          import { ParseError } from "./parse-error";
          Severity: Minor
          Found in lib/message/parser/irc-message.spec.ts - About 2 hrs to fix

            File client.ts has 267 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import * as debugLogger from "debug-logger";
            import { getMods, getVips } from "../operations/get-mods-vips";
            import { ClientConfiguration } from "../config/config";
            import { Color } from "../message/color";
            import { ClientMixin, ConnectionMixin } from "../mixins/base-mixin";
            Severity: Minor
            Found in lib/client/client.ts - About 2 hrs to fix

              File tag-values.spec.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { assert } from "chai";
              import { assertThrowsChain } from "../../helpers.spec";
              import { TwitchBadge } from "../badge";
              import { TwitchBadgesList } from "../badges";
              import { TwitchEmote } from "../emote";
              Severity: Minor
              Found in lib/message/parser/tag-values.spec.ts - About 2 hrs to fix

                Function expandTransportConfig has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                export function expandTransportConfig(
                  config: TransportConfiguration | undefined
                ): ExpandedTransportConfiguration {
                  if (config == null) {
                    return expandTransportConfig({
                Severity: Minor
                Found in lib/config/expanded.ts - About 2 hrs 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 acquire has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private async acquire(
                    channelName: string
                  ): Promise<(() => void) | undefined> {
                    const { fastSpam, certain } = canSpamFast(
                      channelName,
                Severity: Minor
                Found in lib/mixins/ratelimiters/slow-mode.ts - About 1 hr to fix

                  Function expandTransportConfig has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function expandTransportConfig(
                    config: TransportConfiguration | undefined
                  ): ExpandedTransportConfiguration {
                    if (config == null) {
                      return expandTransportConfig({
                  Severity: Minor
                  Found in lib/config/expanded.ts - About 1 hr to fix

                    Function parseEmotes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function parseEmotes(
                      messageText: string,
                      emotesSrc: string
                    ): TwitchEmoteList {
                      const emotes: TwitchEmoteList = [];
                    Severity: Minor
                    Found in lib/message/parser/emotes.ts - About 1 hr 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 newConnection has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public newConnection(): SingleConnection {
                        const conn = new SingleConnection(this.configuration);
                    
                        log.debug(`Creating new connection (ID ${conn.connectionID})`);
                    
                    
                    Severity: Minor
                    Found in lib/client/client.ts - About 1 hr to fix

                      Function applyToClient has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        public applyToClient(client: ChatClient): void {
                          type GenericReplacementFn = (
                            oldFn: (channelName: string, message: string) => Promise<void>,
                            channelName: string,
                            message: string
                      Severity: Minor
                      Found in lib/mixins/alternate-message-modifier.ts - About 1 hr to fix

                        Function parseFlags has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function parseFlags(
                          messageText: string,
                          flagsSrc: string
                        ): TwitchFlagList {
                          const flags: TwitchFlagList = [];
                        Severity: Minor
                        Found in lib/message/parser/flags.ts - About 1 hr 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 constructor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          public constructor(configuration?: ClientConfiguration) {
                            super(configuration);
                        
                            this.on("error", (e) => {
                              if (anyCauseInstanceof(e, ConnectionError)) {
                        Severity: Minor
                        Found in lib/client/connection.ts - About 1 hr to fix

                          Function createMockTransport has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function createMockTransport(): MockTransportData {
                            const data: any[] = [];
                          
                            const transport = new Duplex({
                              autoDestroy: true,
                          Severity: Minor
                          Found in lib/helpers.spec.ts - About 1 hr to fix

                            Function fakeClient has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function fakeClient(connect = true): FakeClientData {
                              const transports: MockTransportData[] = [];
                            
                              const getStream = (): Duplex => {
                                const newTransport = createMockTransport();
                            Severity: Minor
                            Found in lib/helpers.spec.ts - About 1 hr to fix

                              Function applyToClient has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                public applyToClient(client: ChatClient): void {
                                  const genericReplament = async (
                                    oldFn: (channelName: string, message: string) => Promise<void>,
                                    channelName: string,
                                    message: string
                              Severity: Minor
                              Found in lib/mixins/ratelimiters/slow-mode.ts - About 1 hr to fix

                                Function splitIntoChunks has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export function splitIntoChunks(
                                  bits: string[],
                                  separator = " ",
                                  limit: number
                                ): string[][] {
                                Severity: Minor
                                Found in lib/utils/split-into-chunks.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language