JiPaix/xdccJS

View on GitHub
src/bin/commander.ts

Summary

Maintainability
B
4 hrs
Test Coverage

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

      Avoid too many return statements within this function.
      Open

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

        There are no issues that match your filters.

        Category
        Status