robotty/dank-twitch-irc

View on GitHub

Showing 169 of 169 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      assert.deepStrictEqual(
        actual,
        new IRCMessage({
          rawSource: ":leppunen PRIVMSG",
          ircPrefixRaw: "leppunen",
Severity: Major
Found in lib/message/parser/irc-message.spec.ts and 1 other location - About 1 hr to fix
lib/message/parser/irc-message.spec.ts on lines 142..156

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 64.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it("should error on empty prefix", function () {
              assertThrowsChain(
                () => parseIRCMessage(": PING xD"),
                ParseError,
                'Empty prefix declaration (nothing after : sign) (given src: ": PING xD")'
        Severity: Major
        Found in lib/message/parser/irc-message.spec.ts and 1 other location - About 1 hr to fix
        lib/message/parser/badges.spec.ts on lines 48..64

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it("should not prepend a slash to other messages", function () {
              assert.strictEqual(removeCommands(""), "");
              assert.strictEqual(removeCommands("\\me hi"), "\\me hi");
              assert.strictEqual(removeCommands("hello world!"), "hello world!");
            });
        Severity: Major
        Found in lib/operations/say.spec.ts and 1 other location - About 1 hr to fix
        lib/operations/say.spec.ts on lines 9..16

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it("should remove all twitch commands", function () {
              assert.strictEqual(removeCommands("/me hi"), "/ /me hi");
              assert.strictEqual(removeCommands(".me hi"), "/ .me hi");
              assert.strictEqual(
                removeCommands("/timeout weeb123 5"),
        Severity: Major
        Found in lib/operations/say.spec.ts and 1 other location - About 1 hr to fix
        lib/operations/say.spec.ts on lines 18..22

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it("should throw ParseError if no / is present", function () {
              assertThrowsChain(
                () => parseSingleBadge("subscriber12"),
                ParseError,
                "Badge source \"subscriber12\" did not contain '/' character"
        Severity: Major
        Found in lib/message/parser/badges.spec.ts and 1 other location - About 1 hr to fix
        lib/message/parser/irc-message.spec.ts on lines 24..40

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function parseFlags has 32 lines of code (exceeds 25 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

          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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                public async getVips(channelName: string): Promise<string[]> {
                  channelName = correctChannelName(channelName);
                  validateChannelName(channelName);
                  return await getVips(this.requireConnection(), channelName);
                }
              Severity: Major
              Found in lib/client/client.ts and 1 other location - About 1 hr to fix
              lib/client/client.ts on lines 235..239

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 60.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function splitIntoChunks has a Cognitive Complexity of 11 (exceeds 5 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

              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                public async getMods(channelName: string): Promise<string[]> {
                  channelName = correctChannelName(channelName);
                  validateChannelName(channelName);
                  return await getMods(this.requireConnection(), channelName);
                }
              Severity: Major
              Found in lib/client/client.ts and 1 other location - About 1 hr to fix
              lib/client/client.ts on lines 241..245

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 60.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function constructor has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public constructor(message: IRCMessageData) {
                  super(message);
              
                  this.messageText = getParameter(this, 1);
              
              
              Severity: Minor
              Found in lib/message/twitch-types/usernotice.ts - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                export class PongMessage extends IRCMessage {
                  public readonly argument: string | undefined;
                  public constructor(message: IRCMessageData) {
                    super(message);
                
                
                Severity: Major
                Found in lib/message/twitch-types/connection/pong.ts and 1 other location - About 1 hr to fix
                lib/message/twitch-types/connection/ping.ts on lines 7..14

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 59.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Function getModsOrVips has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function getModsOrVips(
                  conn: SingleConnection,
                  channelName: string,
                  config: GetUsersConfig
                ): Promise<string[]> {
                Severity: Minor
                Found in lib/operations/get-mods-vips.ts - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  export class PingMessage extends IRCMessage {
                    public readonly argument: string | undefined;
                    public constructor(message: IRCMessageData) {
                      super(message);
                  
                  
                  Severity: Major
                  Found in lib/message/twitch-types/connection/ping.ts and 1 other location - About 1 hr to fix
                  lib/message/twitch-types/connection/pong.ts on lines 7..14

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 59.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      clientError: new Promise<void>((resolve, reject) => {
                        fakeConn.once("error", (e) => reject(e));
                        fakeConn.once("close", () => resolve());
                      }),
                  Severity: Major
                  Found in lib/helpers.spec.ts and 1 other location - About 1 hr to fix
                  lib/helpers.spec.ts on lines 234..237

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 58.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language