JiPaix/xdccJS

View on GitHub

Showing 33 of 53 total issues

Function config has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  config(params: Partial<{
    passivePort: number[],
    throttle: number,
    nickname: string,
    chan: string[],
Severity: Major
Found in src/bridge.ts - About 3 hrs to fix

    Function config has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      config(params: Partial<{
        passivePort: number[],
        throttle: number,
        nickname: string,
        chan: string[],
    Severity: Minor
    Found in src/bridge.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 checkParams has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static checkParams(params: Partial<ParamsDL>):ParamsDL {
        const testedParams = params;
    
        testedParams.nickname = testedParams.nickname || 'xdccJS';
        testedParams.path = Bridge.pathCheck(params.path);
    Severity: Major
    Found in src/bridge.ts - About 2 hrs to fix

      File downloader.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* eslint-disable max-len */
      /* eslint-disable no-param-reassign */
      import * as fs from 'fs';
      import * as net from 'net';
      import { PassThrough } from 'stream';
      Severity: Minor
      Found in src/downloader.ts - About 2 hrs to fix

        Function prepareDL has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private prepareDL(downloadrequest: { fileInfo: FileInfo; candidate: Job }): void {
            const { fileInfo } = downloadrequest;
            const { candidate } = downloadrequest;
            const stream = this.setupStream(fileInfo);
            if (fileInfo.port === 0) {
        Severity: Minor
        Found in src/downloader.ts - About 1 hr to fix

          Function postToDiscord has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function postToDiscord():Promise<void> {
            return new Promise((resolve, reject) => {
              const discord = new Client({
                intents: [GatewayIntentBits.Guilds],
              });
          Severity: Minor
          Found in build/changelog.ts - About 1 hr to fix

            Function downloadWith has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              private downloadWith(opts: [Params, savedParams]): void {
                if (!this.hasProfileAction()) {
                  if (!this.program.bot && !opts[1].bot) {
                    throw new BinError('%danger% Missing bot name, eg. %grey%--bot "XDCC|BOT"');
                  }
            Severity: Minor
            Found in src/bin/xdccjs.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 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor(params: ParamsIRC) {
                super();
                this.nickname = params.nickname;
                this.originalNickname = this.nickname;
                this.nickRandomized = params.randomizeNick;
            Severity: Minor
            Found in src/connect.ts - About 1 hr to fix

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

                private parseProgram(): void {
                  this.program
                    .storeOptionsAsProperties()
                    .name('xdccJS')
                    .version(version)
              Severity: Minor
              Found in src/bin/commander.ts - About 1 hr to fix

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

                  private onError(args: Pass, e: Error): void {
                    if (args.received === args.fileInfo.length) return;
                
                    if (e.message === 'cancel') this.emit('debug', 'xdccJS:: TCP_CANCEL');
                    else this.emit('debug', `xdccJS:: TCP_ERROR @ ${e.message}`);
                Severity: Minor
                Found in src/downloader.ts - About 1 hr to fix

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

                    protected xdccJSOPTS(): Params {
                      if (!this.program.host) {
                        if (this.program.saveProfile) throw new BinError('%danger% Saved profile must at least contain a host');
                        throw new BinError('%danger% a hostname is required, eg. %grey%--host irc.server.net');
                      }
                  Severity: Minor
                  Found in src/bin/commander.ts - About 1 hr to fix

                    Function passMessage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private passMessage(job:Job) {
                        const listener = (event: MessageEventArgs) => {
                          if (typeof event.type === 'undefined') return;
                          const regexp = this.queue ? new RegExp(this.queue) : undefined;
                          const regex = regexp && regexp.test(event.message);
                    Severity: Minor
                    Found in src/addjob.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 nickServAuth has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private nickServAuth():Promise<void> {
                        return new Promise((resolve, reject) => {
                          let error = '';
                          let timeout = setTimeout(() => {});
                    
                    
                    Severity: Minor
                    Found in src/connect.ts - About 1 hr to fix

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

                        constructor(params: Params) {
                          // eslint-disable-next-line constructor-super
                          super();
                          this.irc = new Bridge(params);
                          this.listenCustomEvents();
                      Severity: Minor
                      Found in src/index.ts - About 1 hr to fix

                        Function processDL has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private processDL(
                            server: net.Server | undefined,
                            client: net.Socket,
                            stream: fs.WriteStream | PassThrough,
                            candidate: Job,
                        Severity: Minor
                        Found in src/downloader.ts - About 1 hr to fix

                          Function onError has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            private onError(args: Pass, e: Error): void {
                              if (args.received === args.fileInfo.length) return;
                          
                              if (e.message === 'cancel') this.emit('debug', 'xdccJS:: TCP_CANCEL');
                              else this.emit('debug', `xdccJS:: TCP_ERROR @ ${e.message}`);
                          Severity: Minor
                          Found in src/downloader.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 downloadWith has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private downloadWith(opts: [Params, savedParams]): void {
                              if (!this.hasProfileAction()) {
                                if (!this.program.bot && !opts[1].bot) {
                                  throw new BinError('%danger% Missing bot name, eg. %grey%--bot "XDCC|BOT"');
                                }
                          Severity: Minor
                          Found in src/bin/xdccjs.ts - About 1 hr to fix

                            Function parameters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              protected get parameters() {
                                const {
                                  passivePort,
                                  throttle,
                                  nickname,
                            Severity: Minor
                            Found in src/bridge.ts - About 1 hr to fix

                              Function onNext has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                protected onNext(): void {
                                  this.on('next', (candidate: Job, verbose:boolean) => {
                                    this.emit('debug', 'xdccJS:: DOWNLOAD_NEXT');
                                    if (candidate.queue.length) {
                                      this.prepareCandidate(candidate);
                              Severity: Minor
                              Found in src/addjob.ts - About 1 hr to fix

                                Function xdccJSOPTS has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  protected xdccJSOPTS(): Params {
                                    if (!this.program.host) {
                                      if (this.program.saveProfile) throw new BinError('%danger% Saved profile must at least contain a host');
                                      throw new BinError('%danger% a hostname is required, eg. %grey%--host irc.server.net');
                                    }
                                Severity: Minor
                                Found in src/bin/commander.ts - About 55 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

                                Severity
                                Category
                                Status
                                Source
                                Language