JiPaix/xdccJS

View on GitHub

Showing 33 of 53 total issues

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

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

    Avoid too many return statements within this function.
    Open

        if (this.program.listProfile && this.program.setProfile) return true;
    Severity: Major
    Found in src/bin/profiles.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

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

        Avoid too many return statements within this function.
        Open

            if (this.program.saveProfile && this.program.setProfile) return true;
        Severity: Major
        Found in src/bin/profiles.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

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

            Avoid too many return statements within this function.
            Open

                    return reject(e);
            Severity: Major
            Found in build/changelog.ts - About 30 mins to fix

              Function download has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                public async download(
                  target: string,
                  packets: Packets,
                  opts?: Partial<{ ipv6:boolean, throttle: number }>,
                ): Promise<Job> {
              Severity: Minor
              Found in src/addjob.ts - About 25 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 SecurityCheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                private SecurityCheck(nick: string, candidate?: Job): boolean {
                  if (candidate) {
                    nick = nick.toLowerCase();
                    candidate.nick = candidate.nick.toLowerCase();
                    candidate.cancelNick = nick;
              Severity: Minor
              Found in src/ctcp_parser.ts - About 25 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