szimek/signature_pad

View on GitHub

Showing 8 of 20 total issues

Function _strokeUpdate has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private _strokeUpdate(event: SignatureEvent): void {
    if (this._data.length === 0) {
      // This can happen if clear() was called while a signature is still in progress,
      // or if there is a race condition between start/update events.
      this._strokeBegin(event);
Severity: Minor
Found in src/signature_pad.ts - About 1 hr to fix

    Function _fromData has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      private _fromData(
        pointGroups: PointGroup[],
        drawCurve: SignaturePad['_drawCurve'],
        drawDot: SignaturePad['_drawDot'],
      ): void {
    Severity: Minor
    Found in src/signature_pad.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 throttle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    export function throttle(
      fn: (...args: any[]) => any,
      wait = 250,
    ): (this: any, ...args: any[]) => any {
      let previous = 0;
    Severity: Minor
    Found in src/throttle.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 throttle has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function throttle(
      fn: (...args: any[]) => any,
      wait = 250,
    ): (this: any, ...args: any[]) => any {
      let previous = 0;
    Severity: Minor
    Found in src/throttle.ts - About 1 hr to fix

      Function _fromData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private _fromData(
          pointGroups: PointGroup[],
          drawCurve: SignaturePad['_drawCurve'],
          drawDot: SignaturePad['_drawDot'],
        ): void {
      Severity: Minor
      Found in src/signature_pad.ts - About 1 hr to fix

        Function _strokeUpdate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          private _strokeUpdate(event: SignatureEvent): void {
            if (this._data.length === 0) {
              // This can happen if clear() was called while a signature is still in progress,
              // or if there is a race condition between start/update events.
              this._strokeBegin(event);
        Severity: Minor
        Found in src/signature_pad.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 length has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public length(): number {
            const steps = 10;
            let length = 0;
            let px;
            let py;
        Severity: Minor
        Found in src/bezier.ts - About 1 hr to fix

          Function _drawCurve has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private _drawCurve(curve: Bezier, options: PointGroupOptions): void {
              const ctx = this._ctx;
              const widthDelta = curve.endWidth - curve.startWidth;
              // '2' is just an arbitrary number here. If only lenght is used, then
              // there are gaps between curve segments :/
          Severity: Minor
          Found in src/signature_pad.ts - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language