konvajs/konva

View on GitHub

Showing 359 of 359 total issues

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

    if (!triggeredOnShape) {
      this._fire(events.pointerup, {
        evt: evt,
        target: this,
        currentTarget: this,
Severity: Major
Found in src/Stage.ts and 1 other location - About 1 hr to fix
src/Stage.ts on lines 651..658

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

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 _prepareToStringify has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _prepareToStringify<T>(obj: any): T | null {
    var desc;

    obj.visitedByCircularReferenceRemoval = true;

Severity: Minor
Found in src/Util.ts - About 1 hr to fix

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

      _handleMouseDown(e) {
        // do nothing if we already transforming
        // that is possible to trigger with multitouch
        if (this._transforming) {
          return;
    Severity: Minor
    Found in src/shapes/Transformer.ts - About 1 hr to fix

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

        measureSize(text: string) {
          var _context = getDummyContext(),
            fontSize = this.fontSize(),
            metrics: TextMetrics;
      
      
      Severity: Minor
      Found in src/shapes/Text.ts - About 1 hr to fix

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

        export const HSV: Filter = function (imageData) {
          var data = imageData.data,
            nPixels = data.length,
            v = Math.pow(2, this.value()),
            s = Math.pow(2, this.saturation()),
        Severity: Minor
        Found in src/filters/HSV.ts - About 1 hr to fix

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

            _getTransform(): Transform {
              var m: Transform = this._cache.get(TRANSFORM) || new Transform();
              m.reset();
          
              // I was trying to use attributes directly here
          Severity: Minor
          Found in src/Node.ts - About 1 hr to fix

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

              _transformedRect(rect: IRect, top?: Node | null) {
                var points = [
                  { x: rect.x, y: rect.y },
                  { x: rect.x + rect.width, y: rect.y },
                  { x: rect.x + rect.width, y: rect.y + rect.height },
            Severity: Minor
            Found in src/Node.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 _setDragPosition has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _setDragPosition(evt, elem) {
                    // const pointers = this.getStage().getPointersPositions();
                    // const pos = pointers.find(p => p.id === this._dragEventId);
                    const pos = this.getStage()!._getPointerById(elem.pointerId);
                
                
                Severity: Minor
                Found in src/Node.ts - About 1 hr to fix

                  Function convertEndpointToCenterParameterization has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    static convertEndpointToCenterParameterization(
                      x1,
                      y1,
                      x2,
                      y2,
                  Severity: Minor
                  Found in src/shapes/Path.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 _off has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _off(type, name?, callback?) {
                      var evtListeners = this.eventListeners[type],
                        i,
                        evtName,
                        handler;
                  Severity: Minor
                  Found in src/Node.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 t2length has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const t2length = (
                    length: number,
                    totalLength: number,
                    func: (t: number) => number
                  ): number => {
                  Severity: Minor
                  Found in src/BezierFunctions.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 _prepareArrayForTween has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _prepareArrayForTween(startArray, endArray, isClosed) {
                      var n,
                        start: Vector2d[] = [],
                        end: Vector2d[] = [];
                      if (startArray.length > endArray.length) {
                  Severity: Minor
                  Found in src/Util.ts - About 1 hr to fix

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

                    export const Solarize: Filter = function (imageData) {
                      var data = imageData.data,
                        w = imageData.width,
                        h = imageData.height,
                        w4 = w * 4,
                    Severity: Minor
                    Found in src/filters/Solarize.ts - About 1 hr to fix

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

                        getIntersection(pos: Vector2d) {
                          if (!this.isListening() || !this.isVisible()) {
                            return null;
                          }
                          // in some cases antialiased area may be bigger than 1px
                      Severity: Minor
                      Found in src/Layer.ts - About 1 hr to fix

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

                              while (n < len - 2) {
                                context.bezierCurveTo(
                                  tp[n++],
                                  tp[n++],
                                  tp[n++],
                        Severity: Major
                        Found in src/shapes/Line.ts and 1 other location - About 1 hr to fix
                        src/shapes/Line.ts on lines 157..166

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

                              while (n < length) {
                                context.bezierCurveTo(
                                  points[n++],
                                  points[n++],
                                  points[n++],
                        Severity: Major
                        Found in src/shapes/Line.ts and 1 other location - About 1 hr to fix
                        src/shapes/Line.ts on lines 134..143

                        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

                        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

                        Function t2length has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const t2length = (
                          length: number,
                          totalLength: number,
                          func: (t: number) => number
                        ): number => {
                        Severity: Minor
                        Found in src/BezierFunctions.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language