konvajs/konva

View on GitHub

Showing 354 of 354 total issues

Function _tweenFunc has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  _tweenFunc(i) {
    var node = this.node,
      attrs = Tween.attrs[node._id][this._id],
      key,
      attr,
Severity: Minor
Found in src/Tween.ts - About 3 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

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

    if (cachedCanvas) {
      context.save();

      var m = this.getAbsoluteTransform(top).getMatrix();
      context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
Severity: Major
Found in src/Shape.ts and 1 other location - About 3 hrs to fix
src/Shape.ts on lines 669..678

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

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 (cachedHitCanvas) {
      context.save();

      var m = this.getAbsoluteTransform(top).getMatrix();
      context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
Severity: Major
Found in src/Shape.ts and 1 other location - About 3 hrs to fix
src/Shape.ts on lines 594..602

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

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

export const Enhance: Filter = function (imageData) {
  var data = imageData.data,
    nSubPixels = data.length,
    rMin = data[0],
    rMax = rMin,
Severity: Major
Found in src/filters/Enhance.ts - About 3 hrs to fix

    Function _pointerup has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _pointerup(evt) {
        const events = getEventsMap(evt.type);
        const eventType = getEventType(evt.type);
    
        if (!events) {
    Severity: Major
    Found in src/Stage.ts - About 3 hrs to fix

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

          if (cachedHitCanvas) {
            context.save();
            var m = this.getAbsoluteTransform(top).getMatrix();
            context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
            this._drawCachedHitCanvas(context);
      Severity: Major
      Found in src/Container.ts and 1 other location - About 3 hrs to fix
      src/Container.ts on lines 357..365

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

      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 (cachedSceneCanvas) {
            context.save();
            var m = this.getAbsoluteTransform(top).getMatrix();
            context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
            this._drawCachedSceneCanvas(context);
      Severity: Major
      Found in src/Container.ts and 1 other location - About 3 hrs to fix
      src/Container.ts on lines 379..387

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

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

        getSelfRect() {
          var points: Array<number> = [];
          this.dataArray.forEach(function (data) {
            if (data.command === 'A') {
              // Approximates by breaking curve into line segments
      Severity: Major
      Found in src/shapes/Path.ts - About 3 hrs to fix

        Function _sceneFunc has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _sceneFunc(context: Context) {
            var width = this.width(),
              height = this.height(),
              pointerDirection = this.pointerDirection(),
              pointerWidth = this.pointerWidth(),
        Severity: Major
        Found in src/shapes/Label.ts - About 3 hrs to fix

          Function getPointAtLengthOfDataArray has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static getPointAtLengthOfDataArray(length: number, dataArray) {
              var point,
                i = 0,
                ii = dataArray.length;
          
          
          Severity: Major
          Found in src/shapes/Path.ts - About 3 hrs to fix

            File TextPath.ts has 290 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Util } from '../Util';
            import { Factory } from '../Factory';
            import { Context } from '../Context';
            import { Shape, ShapeConfig } from '../Shape';
            import { Path } from './Path';
            Severity: Minor
            Found in src/shapes/TextPath.ts - About 2 hrs to fix

              Function _sceneFunc has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _sceneFunc(ctx: Context) {
                  super._sceneFunc(ctx);
                  var PI2 = Math.PI * 2;
                  var points = this.points();
              
              
              Severity: Major
              Found in src/shapes/Arrow.ts - About 2 hrs to fix

                Function calcLength has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static calcLength(x, y, cmd, points) {
                    var len, p1, p2, t;
                    var path = Path;
                
                    switch (cmd) {
                Severity: Major
                Found in src/shapes/Path.ts - About 2 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 Pixelate has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const Pixelate: Filter = function (imageData) {
                    var pixelSize = Math.ceil(this.pixelSize()),
                      width = imageData.width,
                      height = imageData.height,
                      x,
                  Severity: Major
                  Found in src/filters/Pixelate.ts - About 2 hrs to fix

                    Function _addAttr has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _addAttr(key, end) {
                        var node = this.node,
                          nodeId = node._id,
                          start,
                          diff,
                    Severity: Major
                    Found in src/Tween.ts - About 2 hrs to fix

                      Function _setTextData has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _setTextData() {
                          const { width, height } = this._getTextSize(this.attrs.text);
                          this.textWidth = width;
                          this.textHeight = height;
                          this.glyphInfo = [];
                      Severity: Major
                      Found in src/shapes/TextPath.ts - About 2 hrs to fix

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

                                var comparePoint = centeredScaling
                                  ? {
                                      x: this.width() / 2,
                                      y: this.height() / 2,
                                    }
                        Severity: Major
                        Found in src/shapes/Transformer.ts and 3 other locations - About 2 hrs to fix
                        src/shapes/Transformer.ts on lines 798..806
                        src/shapes/Transformer.ts on lines 834..842
                        src/shapes/Transformer.ts on lines 868..876

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

                        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

                          removeChildren() {
                            this.getChildren().forEach((child) => {
                              // reset parent to prevent many _setChildrenIndices calls
                              child.parent = null;
                              child.index = 0;
                        Severity: Major
                        Found in src/Container.ts and 1 other location - About 2 hrs to fix
                        src/Container.ts on lines 99..110

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

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

                                var comparePoint = centeredScaling
                                  ? {
                                      x: this.width() / 2,
                                      y: this.height() / 2,
                                    }
                        Severity: Major
                        Found in src/shapes/Transformer.ts and 3 other locations - About 2 hrs to fix
                        src/shapes/Transformer.ts on lines 770..778
                        src/shapes/Transformer.ts on lines 798..806
                        src/shapes/Transformer.ts on lines 834..842

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language