szimek/signature_pad

View on GitHub

Showing 20 of 22 total issues

Function toSVG has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public toSVG({ includeBackgroundColor = false }: ToSVGOptions = {}): string {
    const pointGroups = this._data;
    const ratio = Math.max(window.devicePixelRatio || 1, 1);
    const minX = 0;
    const minY = 0;
Severity: Major
Found in src/signature_pad.ts - About 2 hrs 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 _strokeUpdate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private _strokeUpdate(event: SignatureEvent): void {
          if (!this._drawingStroke) {
            return;
          }
      
      
      Severity: Minor
      Found in src/signature_pad.ts - About 1 hr to fix

        Function _strokeBegin has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private _strokeBegin(event: SignatureEvent): void {
            const cancelled = !this.dispatchEvent(
              new CustomEvent('beginStroke', { detail: event, cancelable: true }),
            );
            if (cancelled) {
        Severity: Minor
        Found in src/signature_pad.ts - About 1 hr to fix

          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 length is used, then
                // there are gaps between curve segments :/
            Severity: Minor
            Found in src/signature_pad.ts - About 1 hr to fix

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

                removeEventListener(
                  type: string,
                  callback: EventListenerOrEventListenerObject | null,
                  options?: boolean | EventListenerOptions,
                ): void {
              Severity: Minor
              Found in src/signature_event_target.ts and 1 other location - About 55 mins to fix
              src/signature_event_target.ts on lines 16..22

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

              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

                addEventListener(
                  type: string,
                  listener: EventListenerOrEventListenerObject | null,
                  options?: boolean | AddEventListenerOptions,
                ): void {
              Severity: Minor
              Found in src/signature_event_target.ts and 1 other location - About 55 mins to fix
              src/signature_event_target.ts on lines 28..34

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

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

                private _strokeUpdate(event: SignatureEvent): void {
                  if (!this._drawingStroke) {
                    return;
                  }
              
              
              Severity: Minor
              Found in src/signature_pad.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

                    const cy = this.point(
                      t,
                      this.startPoint.y,
                      this.control1.y,
                      this.control2.y,
              Severity: Minor
              Found in src/bezier.ts and 1 other location - About 50 mins to fix
              src/bezier.ts on lines 66..72

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

              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._isLeftButtonPressed(event, true) || !this._drawingStroke) {
                    // Stop when not pressing primary button or pressing multiple buttons
                    this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
                    return;
                  }
              Severity: Minor
              Found in src/signature_pad.ts and 1 other location - About 50 mins to fix
              src/signature_pad.ts on lines 392..396

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

              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

                    const cx = this.point(
                      t,
                      this.startPoint.x,
                      this.control1.x,
                      this.control2.x,
              Severity: Minor
              Found in src/bezier.ts and 1 other location - About 50 mins to fix
              src/bezier.ts on lines 73..79

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

              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._isLeftButtonPressed(event, true) || !this._drawingStroke) {
                    // Stop when primary button not pressed or multiple buttons pressed
                    this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
                    return;
                  }
              Severity: Minor
              Found in src/signature_pad.ts and 1 other location - About 50 mins to fix
              src/signature_pad.ts on lines 316..320

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

              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

                  const m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
              Severity: Minor
              Found in src/bezier.ts and 1 other location - About 45 mins to fix
              src/bezier.ts on lines 28..28

              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

                  const m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
              Severity: Minor
              Found in src/bezier.ts and 1 other location - About 45 mins to fix
              src/bezier.ts on lines 27..27

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

                          `M ${curve.startPoint.x.toFixed(3)},${curve.startPoint.y.toFixed(
                            3,
                          )} ` +
                          `C ${curve.control1.x.toFixed(3)},${curve.control1.y.toFixed(3)} ` +
              Severity: Minor
              Found in src/signature_pad.ts and 2 other locations - About 35 mins to fix
              src/signature_pad.ts on lines 762..766
              src/signature_pad.ts on lines 762..767

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

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

                private _getPointGroupOptions(group?: PointGroup): PointGroupOptions {
                  return {
                    penColor: group && 'penColor' in group ? group.penColor : this.penColor,
                    dotSize: group && 'dotSize' in group ? group.dotSize : this.dotSize,
                    minWidth: group && 'minWidth' in group ? group.minWidth : this.minWidth,
              Severity: Minor
              Found in src/signature_pad.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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                constructor(
                  private canvas: HTMLCanvasElement,
                  options: Options = {},
                ) {
                  super();
              Severity: Minor
              Found in src/signature_pad.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