konvajs/konva

View on GitHub
src/Context.ts

Summary

Maintainability
F
6 days
Test Coverage

File Context.ts has 667 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Util } from './Util';
import { Konva } from './Global';
import { Canvas } from './Canvas';
import { Shape } from './Shape';
import { IRect } from './types';
Severity: Major
Found in src/Context.ts - About 1 day to fix

    Context has 55 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Context {
      canvas: Canvas;
      _context: CanvasRenderingContext2D;
      traceArr: Array<String>;
    
    
    Severity: Major
    Found in src/Context.ts - About 7 hrs to fix

      Function getTrace has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        getTrace(relaxed?: boolean, rounded?: boolean) {
          var traceArr = this.traceArr,
            len = traceArr.length,
            str = '',
            n,
      Severity: Minor
      Found in src/Context.ts - About 2 hrs 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 _enableTrace has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _enableTrace() {
          var that = this,
            len = CONTEXT_METHODS.length,
            origSetter = this.setAttr,
            n,
      Severity: Minor
      Found in src/Context.ts - About 1 hr to fix

        Function getTrace has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getTrace(relaxed?: boolean, rounded?: boolean) {
            var traceArr = this.traceArr,
              len = traceArr.length,
              str = '',
              n,
        Severity: Minor
        Found in src/Context.ts - About 1 hr to fix

          Function _stroke has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            _stroke(shape) {
              var dash = shape.dash(),
                // ignore strokeScaleEnabled for Text
                strokeScaleEnabled = shape.getStrokeScaleEnabled();
          
          
          Severity: Minor
          Found in src/Context.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 _fill has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _fill(shape) {
              const hasColor = shape.fill(),
                fillPriority = shape.getFillPriority();
          
              // priority fills
          Severity: Minor
          Found in src/Context.ts - About 1 hr to fix

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

              _stroke(shape) {
                var dash = shape.dash(),
                  // ignore strokeScaleEnabled for Text
                  strokeScaleEnabled = shape.getStrokeScaleEnabled();
            
            
            Severity: Minor
            Found in src/Context.ts - About 1 hr to fix

              Function _fill has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                _fill(shape) {
                  const hasColor = shape.fill(),
                    fillPriority = shape.getFillPriority();
              
                  // priority fills
              Severity: Minor
              Found in src/Context.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

              Avoid deeply nested control flow statements.
              Open

                          if (rounded) {
                            args = args.map((a) =>
                              typeof a === 'number' ? Math.floor(a) : a
                            );
                          }
              Severity: Major
              Found in src/Context.ts - About 45 mins to fix

                Function _stroke has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  _stroke(shape) {
                    if (shape.hasHitStroke()) {
                      // ignore strokeScaleEnabled for Text
                      const strokeScaleEnabled = shape.getStrokeScaleEnabled();
                      if (!strokeScaleEnabled) {
                Severity: Minor
                Found in src/Context.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

                Identical blocks of code found in 3 locations. Consider refactoring.
                Open

                      for (var n = 0; n < colorStops.length; n += 2) {
                        grd.addColorStop(colorStops[n] as number, colorStops[n + 1] as string);
                      }
                Severity: Major
                Found in src/Context.ts and 2 other locations - About 1 hr to fix
                src/Shape.ts on lines 301..303
                src/Shape.ts on lines 328..330

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

                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

                  setTransform(
                    a: number,
                    b: number,
                    c: number,
                    d: number,
                Severity: Major
                Found in src/Context.ts and 2 other locations - About 1 hr to fix
                src/Context.ts on lines 352..361
                src/Context.ts on lines 719..721

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

                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

                  transform(a: number, b: number, c: number, d: number, e: number, f: number) {
                    this._context.transform(a, b, c, d, e, f);
                  }
                Severity: Major
                Found in src/Context.ts and 2 other locations - About 1 hr to fix
                src/Context.ts on lines 352..361
                src/Context.ts on lines 684..693

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

                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

                  bezierCurveTo(
                    cp1x: number,
                    cp1y: number,
                    cp2x: number,
                    cp2y: number,
                Severity: Major
                Found in src/Context.ts and 2 other locations - About 1 hr to fix
                src/Context.ts on lines 684..693
                src/Context.ts on lines 719..721

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

                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

                  _fillRadialGradient(shape: Shape) {
                    const grd = shape._getRadialGradient();
                    if (grd) {
                      this.setAttr('fillStyle', grd);
                      shape._fillFunc(this);
                Severity: Major
                Found in src/Context.ts and 1 other location - About 1 hr to fix
                src/Context.ts on lines 822..829

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

                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

                  _fillLinearGradient(shape: Shape) {
                    var grd = shape._getLinearGradient();
                
                    if (grd) {
                      this.setAttr('fillStyle', grd);
                Severity: Major
                Found in src/Context.ts and 1 other location - About 1 hr to fix
                src/Context.ts on lines 830..836

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

                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

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

                      if (!strokeScaleEnabled) {
                        this.save();
                        var pixelRatio = this.getCanvas().getPixelRatio();
                        this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
                      }
                Severity: Major
                Found in src/Context.ts and 1 other location - About 1 hr to fix
                src/Context.ts on lines 896..900

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

                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

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

                      if (!strokeScaleEnabled) {
                        this.save();
                        var pixelRatio = this.getCanvas().getPixelRatio();
                        this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
                      }
                Severity: Major
                Found in src/Context.ts and 1 other location - About 1 hr to fix
                src/Context.ts on lines 972..976

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

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

                  quadraticCurveTo(cpx: number, cpy: number, x: number, y: number) {
                    this._context.quadraticCurveTo(cpx, cpy, x, y);
                  }
                Severity: Major
                Found in src/Context.ts and 4 other locations - About 45 mins to fix
                src/Context.ts on lines 367..369
                src/Context.ts on lines 527..529
                src/Context.ts on lines 535..537
                src/Context.ts on lines 587..589

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

                  strokeRect(x: number, y: number, width: number, height: number) {
                    this._context.strokeRect(x, y, width, height);
                  }
                Severity: Major
                Found in src/Context.ts and 4 other locations - About 45 mins to fix
                src/Context.ts on lines 367..369
                src/Context.ts on lines 527..529
                src/Context.ts on lines 587..589
                src/Context.ts on lines 617..619

                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

                  createLinearGradient(x0: number, y0: number, x1: number, y1: number) {
                    return this._context.createLinearGradient(x0, y0, x1, y1);
                  }
                Severity: Minor
                Found in src/Context.ts and 1 other location - About 45 mins to fix
                src/Context.ts on lines 563..565

                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

                  getImageData(sx: number, sy: number, sw: number, sh: number) {
                    return this._context.getImageData(sx, sy, sw, sh);
                  }
                Severity: Minor
                Found in src/Context.ts and 1 other location - About 45 mins to fix
                src/Context.ts on lines 406..408

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

                  fillRect(x: number, y: number, width: number, height: number) {
                    this._context.fillRect(x, y, width, height);
                  }
                Severity: Major
                Found in src/Context.ts and 4 other locations - About 45 mins to fix
                src/Context.ts on lines 367..369
                src/Context.ts on lines 535..537
                src/Context.ts on lines 587..589
                src/Context.ts on lines 617..619

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

                  rect(x: number, y: number, width: number, height: number) {
                    this._context.rect(x, y, width, height);
                  }
                Severity: Major
                Found in src/Context.ts and 4 other locations - About 45 mins to fix
                src/Context.ts on lines 367..369
                src/Context.ts on lines 527..529
                src/Context.ts on lines 535..537
                src/Context.ts on lines 617..619

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

                  clearRect(x: number, y: number, width: number, height: number) {
                    this._context.clearRect(x, y, width, height);
                  }
                Severity: Major
                Found in src/Context.ts and 4 other locations - About 45 mins to fix
                src/Context.ts on lines 527..529
                src/Context.ts on lines 535..537
                src/Context.ts on lines 587..589
                src/Context.ts on lines 617..619

                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

                  _applyLineJoin(shape: Shape) {
                    const lineJoin = shape.attrs.lineJoin;
                    if (lineJoin) {
                      this.setAttr('lineJoin', lineJoin);
                    }
                Severity: Minor
                Found in src/Context.ts and 1 other location - About 40 mins to fix
                src/Context.ts on lines 291..296

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

                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

                  _applyLineCap(shape: Shape) {
                    const lineCap = shape.attrs.lineCap;
                    if (lineCap) {
                      this.setAttr('lineCap', lineCap);
                    }
                Severity: Minor
                Found in src/Context.ts and 1 other location - About 40 mins to fix
                src/Context.ts on lines 303..308

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

                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

                There are no issues that match your filters.

                Category
                Status