konvajs/konva

View on GitHub

Showing 354 of 354 total issues

File Text.ts has 523 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Util } from '../Util';
import { Context } from '../Context';
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { Konva } from '../Global';
Severity: Major
Found in src/shapes/Text.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 _handleMouseMove has 193 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _handleMouseMove(e) {
          var x, y, newHypotenuse;
          var anchorNode = this.findOne('.' + this._movingAnchorName)!;
          var stage = anchorNode.getStage()!;
      
      
      Severity: Major
      Found in src/shapes/Transformer.ts - About 7 hrs to fix

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

            if (typeof cornerRadius === 'number') {
              topLeft =
                topRight =
                bottomLeft =
                bottomRight =
        Severity: Major
        Found in src/shapes/Label.ts and 1 other location - About 7 hrs to fix
        src/Util.ts on lines 1003..1014

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

        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 (typeof cornerRadius === 'number') {
              topLeft =
                topRight =
                bottomLeft =
                bottomRight =
        Severity: Major
        Found in src/Util.ts and 1 other location - About 7 hrs to fix
        src/shapes/Label.ts on lines 215..226

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

        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

        Util has 50 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export const Util = {
          /*
           * cherry-picked utilities from underscore.js
           */
          _isElement(obj: any): obj is Element {
        Severity: Minor
        Found in src/Util.ts - About 7 hrs to fix

          Function _sceneFunc has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
          Open

            _sceneFunc(context: Context) {
              var textArr = this.textArr,
                textArrLen = textArr.length;
          
              if (!this.text()) {
          Severity: Minor
          Found in src/shapes/Text.ts - About 6 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

              points.forEach(function (point) {
                var transformed = trans.point(point);
                if (minX === undefined) {
                  minX = maxX = transformed.x;
                  minY = maxY = transformed.y;
          Severity: Major
          Found in src/Node.ts and 1 other location - About 5 hrs to fix
          src/shapes/Transformer.ts on lines 520..530

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

          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

              totalPoints.forEach(function (point) {
                var transformed = tr.point(point);
                if (minX === undefined) {
                  minX = maxX = transformed.x;
                  minY = maxY = transformed.y;
          Severity: Major
          Found in src/shapes/Transformer.ts and 1 other location - About 5 hrs to fix
          src/Node.ts on lines 512..522

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

          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

                    case 't':
                      ctlPtx = cpx;
                      ctlPty = cpy;
                      prevCmd = ca[ca.length - 1];
                      if (prevCmd.command === 'Q') {
          Severity: Major
          Found in src/shapes/Path.ts and 1 other location - About 5 hrs to fix
          src/shapes/Path.ts on lines 681..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 152.

          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

                    case 'T':
                      ctlPtx = cpx;
                      ctlPty = cpy;
                      prevCmd = ca[ca.length - 1];
                      if (prevCmd.command === 'Q') {
          Severity: Major
          Found in src/shapes/Path.ts and 1 other location - About 5 hrs to fix
          src/shapes/Path.ts on lines 694..706

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

          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

          Stage has 42 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class Stage extends Container<Layer> {
            content: HTMLDivElement;
            pointerPos: Vector2d | null;
            _pointerPositions: (Vector2d & { id?: number })[] = [];
            _changedPointerPositions: (Vector2d & { id: number })[] = [];
          Severity: Minor
          Found in src/Stage.ts - About 5 hrs to fix

            Function filterGaussBlurRGBA has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
            Open

            function filterGaussBlurRGBA(imageData, radius) {
              var pixels = imageData.data,
                width = imageData.width,
                height = imageData.height;
            
            
            Severity: Minor
            Found in src/filters/Blur.ts - About 5 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 a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
            Open

            export const Pixelate: Filter = function (imageData) {
              var pixelSize = Math.ceil(this.pixelSize()),
                width = imageData.width,
                height = imageData.height,
                x,
            Severity: Minor
            Found in src/filters/Pixelate.ts - About 5 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 (pa !== 0) {
                    pa = 255 / pa;
                    pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;
                    pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
                    pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
            Severity: Major
            Found in src/filters/Blur.ts and 1 other location - About 5 hrs to fix
            src/filters/Blur.ts on lines 308..315

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

            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 (pa > 0) {
                    pa = 255 / pa;
                    pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;
                    pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
                    pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
            Severity: Major
            Found in src/filters/Blur.ts and 1 other location - About 5 hrs to fix
            src/filters/Blur.ts on lines 198..205

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

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

              _fitNodesInto(newAttrs, evt?) {
                var oldAttrs = this._getNodeRect();
            
                const minSize = 1;
            
            
            Severity: Major
            Found in src/shapes/Transformer.ts - About 5 hrs to fix

              File Container.ts has 374 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { Factory } from './Factory';
              import { Node, NodeConfig } from './Node';
              import { getNumberValidator } from './Validators';
              
              import { GetSet, IRect } from './types';
              Severity: Minor
              Found in src/Container.ts - About 5 hrs to fix

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

                  _sceneFunc(context: Context) {
                    var textArr = this.textArr,
                      textArrLen = textArr.length;
                
                    if (!this.text()) {
                Severity: Major
                Found in src/shapes/Text.ts - About 4 hrs to fix

                  Transformer has 37 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export class Transformer extends Group {
                    _nodes: Array<Node>;
                    _movingAnchorName: string | null = null;
                    _transforming = false;
                    _anchorDragOffset: Vector2d;
                  Severity: Minor
                  Found in src/shapes/Transformer.ts - About 4 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language