JiPaix/xdccJS

View on GitHub

Showing 47 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

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

              if (typeof params.timeout === 'number') {
                this.timeout = Downloader.is({
                  name: 'retry',
                  variable: params.timeout,
                  type: 1,
          Severity: Major
          Found in src/bridge.ts and 1 other location - About 1 hr to fix
          src/bridge.ts on lines 173..181

          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 74.

          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

              if (typeof params.retry === 'number') {
                this.retry = Downloader.is({
                  name: 'retry',
                  variable: params.retry,
                  type: 1,
          Severity: Major
          Found in src/bridge.ts and 1 other location - About 1 hr to fix
          src/bridge.ts on lines 183..191

          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 74.

          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

                this.passivePort = Downloader.is({
                  name: 'passivePort',
                  variable: params.passivePort,
                  type: [5001],
                  condition: !params.passivePort.some((number) => number < 1025 || number > 65535),
          Severity: Major
          Found in src/bridge.ts and 1 other location - About 1 hr to fix
          src/bridge.ts on lines 41..47

          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 72.

          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

              testedParams.passivePort = Downloader.is({
                name: 'passivePort',
                variable: testedParams.passivePort,
                type: [5001],
                condition: !testedParams.passivePort.some((number) => number < 1025 || number > 65535),
          Severity: Major
          Found in src/bridge.ts and 1 other location - About 1 hr to fix
          src/bridge.ts on lines 194..200

          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 72.

          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 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

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

                                testedParams.throttle = Downloader.is({
                                  name: 'throttle',
                                  variable: params.throttle,
                                  type: 10,
                                  condition: testedParams.throttle > 0,
                          Severity: Major
                          Found in src/bridge.ts and 1 other location - About 1 hr to fix
                          src/addjob.ts on lines 37..43

                          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 57.

                          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