perryrh0dan/2fa

View on GitHub

Showing 6 of 8 total issues

Function digest has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function digest(options: HtopGenerateOptions): Buffer {
  // unpack options
  const secret = options.secret;
  const counter = options.counter;
  const encoding = options.encoding || 'ascii';
Severity: Minor
Found in src/hotp/hotp.ts - About 1 hr to fix

    Function digest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    export function digest(options: HtopGenerateOptions): Buffer {
      // unpack options
      const secret = options.secret;
      const counter = options.counter;
      const encoding = options.encoding || 'ascii';
    Severity: Minor
    Found in src/hotp/hotp.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 otpauthURL has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public otpauthURL(options?: Partial<ImageOptions>): string {
        // unpack options
        if (!options) options = {};
        var secret = this.secret;
        var label = this.label;
    Severity: Minor
    Found in src/secret/secret.ts - About 1 hr to fix

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

      export function base32Encode(
        buffer: ArrayBuffer,
        options: Partial<Base32EncodeOptions> = {},
      ): string {
        let alphabet: string;
      Severity: Minor
      Found in src/base32.ts - About 1 hr to fix

        Function otpauthURL has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          public otpauthURL(options?: Partial<ImageOptions>): string {
            // unpack options
            if (!options) options = {};
            var secret = this.secret;
            var label = this.label;
        Severity: Minor
        Found in src/secret/secret.ts - About 45 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 base32Encode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function base32Encode(
          buffer: ArrayBuffer,
          options: Partial<Base32EncodeOptions> = {},
        ): string {
          let alphabet: string;
        Severity: Minor
        Found in src/base32.ts - About 45 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