JiPaix/xdccJS

View on GitHub

Showing 47 of 53 total issues

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 checkParams has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static checkParams(params: Partial<ParamsDL>):ParamsDL {
        return {
          nickname: Bridge.is({ name: 'nickname', variable: params.nickname || 'xdccJS', type: 'string', condition: (params.nickname || 'xdccJS').length > 3, conditionError: 'nickname must contain at least 4 characters' }),
          username: Bridge.is({ name: 'username', variable: params.username || 'xdccJS', type: 'string', condition: (params.username || 'xdccJS').length > 3, conditionError: 'username must contain at least 4 characters' }),
          path: Bridge.pathCheck(params.path),
    Severity: Minor
    Found in src/bridge.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 start has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function start() {
          try {
            const release = await getReleases();
            const find = release.data.find(t => t.tag_name.endsWith(version))
            if(find) return console.log('already released');
        Severity: Minor
        Found in build/changelog.ts - About 1 hr to fix

          Function onData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private onData(args: Pass, data: Buffer, sendBuffer: Buffer): void {
              const startTime = args.startTime || Date.now();
          
              if (args.received === 0) {
                args.startTime = startTime;
          Severity: Minor
          Found in src/downloader.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

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

                    throttle: Bridge.is({ name: 'throttle', variable: params.throttle, type: 0, condition: (params.throttle || 1) < 0, conditionError: 'retry must be larger than 0' }),
              Severity: Major
              Found in src/bridge.ts and 2 other locations - About 1 hr to fix
              src/bridge.ts on lines 44..44
              src/bridge.ts on lines 46..46

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

              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 3 locations. Consider refactoring.
              Open

                    retry: Bridge.is({ name: 'retry', variable: params.retry, type: 1, condition: (params.retry || 1) < 0, conditionError: 'retry must be larger than 0' }),
              Severity: Major
              Found in src/bridge.ts and 2 other locations - About 1 hr to fix
              src/bridge.ts on lines 45..45
              src/bridge.ts on lines 46..46

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

              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 3 locations. Consider refactoring.
              Open

                    timeout: Bridge.is({ name: 'timeout', variable: params.timeout, type: 30, condition: (params.timeout || 1) < 0, conditionError: 'retry must be larger than 0' }),
              Severity: Major
              Found in src/bridge.ts and 2 other locations - About 1 hr to fix
              src/bridge.ts on lines 44..44
              src/bridge.ts on lines 45..45

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

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

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

                private onData(args: Pass, data: Buffer, sendBuffer: Buffer): void {
                  const startTime = args.startTime || Date.now();
              
                  if (args.received === 0) {
                    args.startTime = startTime;
              Severity: Minor
              Found in src/downloader.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

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

                  if (typeof identify !== 'string') {
                    const err = new TypeError();
                    err.name = `${err.name} [ERR_INVALID_ARG_TYPE]`;
                    err.message = 'unexpected type of \'nickServ\': \'string\' was expected\'';
                    throw err;
              Severity: Minor
              Found in src/connect.ts and 1 other location - About 50 mins to fix
              src/connect.ts on lines 321..326

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

              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 (identify.split(' ').length > 1) {
                    const err = new TypeError();
                    err.name = `${err.name} [ERR_INVALID_ARG_TYPE]`;
                    err.message = 'parameter \'nickServ\': should only contain the password (no spaces)';
                    throw err;
              Severity: Minor
              Found in src/connect.ts and 1 other location - About 50 mins to fix
              src/connect.ts on lines 314..319

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

              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(params.verbose !== this.verbose) {
                    this.verbose = params.verbose;
                    this.print(`%success% verbose: %yellow%${this.verbose ? 'on' : 'off'}%reset%`, 2);
                  }
              Severity: Minor
              Found in src/bridge.ts and 1 other location - About 45 mins to fix
              src/bridge.ts on lines 66..69

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

              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 (this.parameters.botNameMatch !== params.botNameMatch) {
                    this.botNameMatch = params.botNameMatch
                    this.print(`%success% botNameMatch: %yellow%${this.botNameMatch ? 'on' : 'off'}%reset%`, 2);
                  }
              Severity: Minor
              Found in src/bridge.ts and 1 other location - About 45 mins to fix
              src/bridge.ts on lines 81..84

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

              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 parseIfNotInt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                private static parseIfNotInt(numstring: string, optName:'port' | 'throttle' | 'passive-port' | 'retry' | 'wait' | 'timeout'): number {
                  const cannotBeLessThanZero = (optName === 'retry' || optName === 'throttle' || optName === 'wait' || optName === 'timeout');
              
                  const notAnumber = Number.isNaN(parseInt(numstring, 10)) || Number.isNaN(parseFloat(numstring));
                  if (notAnumber) throw new BinError(`%danger% option --${optName} must be a number`);
              Severity: Minor
              Found in src/bin/commander.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 hasTooManyProfileAction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                private hasTooManyProfileAction():boolean {
                  if (this.program.deleteProfile && this.program.listProfile) return true;
                  if (this.program.deleteProfile && this.program.saveProfile) return true;
                  if (this.program.deleteProfile && this.program.setProfile) return true;
                  if (this.program.listProfile && this.program.saveProfile) return true;
              Severity: Minor
              Found in src/bin/profiles.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 is has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                static is<T, D>(opts: { name: string, variable: T, type: 'string'|'number'|'boolean'|'object'| D }, condition?: boolean, conditionError?: string): T | D {
                  const { name, variable, type } = opts;
              
                  if (typeof condition !== 'undefined' && !condition) {
                    const err = new TypeError(`condition for '${name}' aren't met: ${conditionError || variable}'`);
              Severity: Minor
              Found in src/connect.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

              Avoid too many return statements within this function.
              Open

                  return false;
              Severity: Major
              Found in src/bin/commander.ts - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language