szimek/signature_pad

View on GitHub

Showing 10 of 21 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 _strokeUpdate has 42 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 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 _strokeUpdate has a Cognitive Complexity of 12 (exceeds 5 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

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

            Function _getPointGroupOptions has a Cognitive Complexity of 6 (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 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 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