konvajs/konva

View on GitHub

Showing 354 of 354 total issues

File Node.ts has 1787 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Util, Transform } from './Util';
import { Factory } from './Factory';
import { SceneCanvas, HitCanvas, Canvas } from './Canvas';
import { Konva } from './Global';
import { Container } from './Container';
Severity: Major
Found in src/Node.ts - About 4 days to fix

    File Transformer.ts has 1151 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Util, Transform } from '../Util';
    import { Factory } from '../Factory';
    import { Node } from '../Node';
    import { Shape } from '../Shape';
    import { Rect } from './Rect';
    Severity: Major
    Found in src/shapes/Transformer.ts - About 2 days to fix

      Node has 111 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export abstract class Node<Config extends NodeConfig = NodeConfig> {
        _id = idCounter++;
        eventListeners: {
          [index: string]: Array<{ name: string; handler: Function }>;
        } = {};
      Severity: Major
      Found in src/Node.ts - About 2 days to fix

        File Util.ts has 848 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Konva } from './Global';
        import { Context } from './Context';
        import { IRect, RGB, RGBA, Vector2d } from './types';
        
        /*
        Severity: Major
        Found in src/Util.ts - About 2 days to fix

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

          function erodeMask(mask, sw, sh) {
            var weights = [1, 1, 1, 1, 0, 1, 1, 1, 1];
            var side = Math.round(Math.sqrt(weights.length));
            var halfSide = Math.floor(side / 2);
          
          
          Severity: Major
          Found in src/filters/Mask.ts and 1 other location - About 1 day to fix
          src/filters/Mask.ts on lines 109..138

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

          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

          function dilateMask(mask, sw, sh) {
            var weights = [1, 1, 1, 1, 1, 1, 1, 1, 1];
            var side = Math.round(Math.sqrt(weights.length));
            var halfSide = Math.floor(side / 2);
          
          
          Severity: Major
          Found in src/filters/Mask.ts and 1 other location - About 1 day to fix
          src/filters/Mask.ts on lines 78..107

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

          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

          File BezierFunctions.ts has 793 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Credits: rveciana/svg-path-properties
          
          // Legendre-Gauss abscissae (xi values, defined at i=n as the roots of the nth order Legendre polynomial Pn(x))
          export const tValues = [
            [],
          Severity: Major
          Found in src/BezierFunctions.ts - About 1 day to fix

            File Shape.ts has 785 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Konva } from './Global';
            import { Transform, Util } from './Util';
            import { Factory } from './Factory';
            import { Node, NodeConfig } from './Node';
            import {
            Severity: Major
            Found in src/Shape.ts - About 1 day to fix

              File Path.ts has 774 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { Factory } from '../Factory';
              import { Shape, ShapeConfig } from '../Shape';
              import { _registerNode } from '../Global';
              
              import { GetSet, PathSegment } from '../types';
              Severity: Major
              Found in src/shapes/Path.ts - About 1 day to fix

                File Stage.ts has 767 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { Util } from './Util';
                import { Factory } from './Factory';
                import { Container, ContainerConfig } from './Container';
                import { Konva } from './Global';
                import { SceneCanvas, HitCanvas } from './Canvas';
                Severity: Major
                Found in src/Stage.ts - About 1 day to fix

                  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

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

                    var mul_table = [
                      512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292,
                      512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292,
                      273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259,
                      496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292,
                    Severity: Major
                    Found in src/filters/Blur.ts and 1 other location - About 1 day to fix
                    src/filters/Blur.ts on lines 77..92

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

                    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

                    var shg_table = [
                      9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17,
                      17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
                      19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
                      20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
                    Severity: Major
                    Found in src/filters/Blur.ts and 1 other location - About 1 day to fix
                    src/filters/Blur.ts on lines 57..75

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

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

                      static parsePathData(data): PathSegment[] {
                        // Path Data Segment must begin with a moveTo
                        //m (x y)+  Relative moveTo (subsequent points are treated as lineTo)
                        //M (x y)+  Absolute moveTo (subsequent points are treated as lineTo)
                        //l (x y)+  Relative lineTo
                    Severity: Major
                    Found in src/shapes/Path.ts - About 1 day to fix

                      Function _setTextData has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
                      Open

                        _setTextData() {
                          var lines = this.text().split('\n'),
                            fontSize = +this.fontSize(),
                            textWidth = 0,
                            lineHeightPx = this.lineHeight() * fontSize,
                      Severity: Minor
                      Found in src/shapes/Text.ts - About 1 day 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 Emboss has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const Emboss: Filter = function (imageData) {
                        // pixastic strength is between 0 and 10.  I want it between 0 and 1
                        // pixastic greyLevel is between 0 and 255.  I want it between 0 and 1.  Also,
                        // a max value of greyLevel yields a white emboss, and the min value yields a black
                        // emboss.  Therefore, I changed greyLevel to whiteLevel
                      Severity: Minor
                      Found in src/filters/Emboss.ts - About 1 day 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 _handleMouseMove has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
                      Open

                        _handleMouseMove(e) {
                          var x, y, newHypotenuse;
                          var anchorNode = this.findOne('.' + this._movingAnchorName)!;
                          var stage = anchorNode.getStage()!;
                      
                      
                      Severity: Minor
                      Found in src/shapes/Transformer.ts - About 1 day 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

                      File Tween.ts has 586 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { Util } from './Util';
                      import { Animation } from './Animation';
                      import { Node, NodeConfig } from './Node';
                      import { Konva } from './Global';
                      import { Line } from './shapes/Line';
                      Severity: Major
                      Found in src/Tween.ts - About 1 day to fix

                        Function parsePathData has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
                        Open

                          static parsePathData(data): PathSegment[] {
                            // Path Data Segment must begin with a moveTo
                            //m (x y)+  Relative moveTo (subsequent points are treated as lineTo)
                            //M (x y)+  Absolute moveTo (subsequent points are treated as lineTo)
                            //l (x y)+  Relative lineTo
                        Severity: Minor
                        Found in src/shapes/Path.ts - About 1 day 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 filterGaussBlurRGBA has 214 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function filterGaussBlurRGBA(imageData, radius) {
                          var pixels = imageData.data,
                            width = imageData.width,
                            height = imageData.height;
                        
                        
                        Severity: Major
                        Found in src/filters/Blur.ts - About 1 day to fix
                          Severity
                          Category
                          Status
                          Source
                          Language