konvajs/konva

View on GitHub

Showing 359 of 359 total issues

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

    var dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];
Severity: Major
Found in src/Util.ts and 1 other location - About 1 hr to fix
src/Util.ts on lines 169..169

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

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/Shape.ts and 2 other locations - About 1 hr to fix
src/Context.ts on lines 884..886
src/Shape.ts on lines 306..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 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

Function drawHit has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  drawHit(can?: HitCanvas, top?: Node, skipDragCheck = false) {
    if (!this.shouldDrawHit(top, skipDragCheck)) {
      return this;
    }

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

    Function _createAnchor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _createAnchor(name) {
        var anchor = new Rect({
          stroke: 'rgb(0, 161, 255)',
          fill: 'white',
          strokeWidth: 1,
    Severity: Minor
    Found in src/shapes/Transformer.ts - About 1 hr to fix

      Function _addListeners has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _addListeners() {
          // start listeners
          this.tween.onPlay = () => {
            this.anim.start();
          };
      Severity: Minor
      Found in src/Tween.ts - About 1 hr to fix

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

        Function Contrast has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const Contrast: Filter = function (imageData) {
          var adjust = Math.pow((this.contrast() + 100) / 100, 2);
        
          var data = imageData.data,
            nPixels = data.length,
        Severity: Minor
        Found in src/filters/Contrast.ts - About 1 hr to fix

          Function ElasticEaseInOut has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            ElasticEaseInOut(t, b, c, d, a, p) {
              // added s = 0
              var s = 0;
              if (t === 0) {
                return b;
          Severity: Minor
          Found in src/Tween.ts - About 1 hr to fix

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

                for (n = 0; n < startArray.length; n += 2) {
                  start.push({
                    x: startArray[n],
                    y: startArray[n + 1],
                  });
            Severity: Major
            Found in src/Util.ts and 1 other location - About 1 hr to fix
            src/Util.ts on lines 921..926

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

            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

                for (n = 0; n < endArray.length; n += 2) {
                  end.push({
                    x: endArray[n],
                    y: endArray[n + 1],
                  });
            Severity: Major
            Found in src/Util.ts and 1 other location - About 1 hr to fix
            src/Util.ts on lines 915..920

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

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

              _sceneFunc(context: Context) {
                context.setAttr('font', this._getContextFont());
                context.setAttr('textBaseline', this.textBaseline());
                context.setAttr('textAlign', 'left');
                context.save();
            Severity: Minor
            Found in src/shapes/TextPath.ts - About 1 hr to fix

              Function _pointerleave has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _pointerleave(evt) {
                  const events = getEventsMap(evt.type);
                  const eventType = getEventType(evt.type);
              
                  if (!events) {
              Severity: Minor
              Found in src/Stage.ts - About 1 hr to fix

                Function _getAbsoluteTransform has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _getAbsoluteTransform(top?: Node) {
                    var at: Transform;
                    // we we need position relative to an ancestor, we will iterate for all
                    if (top) {
                      at = new Transform();
                Severity: Minor
                Found in src/Node.ts - About 1 hr to fix

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

                    _sceneFunc(context: Context) {
                      const width = this.getWidth();
                      const height = this.getHeight();
                      const cornerRadius = this.cornerRadius();
                      const image = this.attrs.image;
                  Severity: Minor
                  Found in src/shapes/Image.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 _addListeners has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _addListeners() {
                      // start listeners
                      this.tween.onPlay = () => {
                        this.anim.start();
                      };
                  Severity: Minor
                  Found in src/Tween.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

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

                      if (index > 0) {
                        this.parent.children.splice(index, 1);
                        this.parent.children.unshift(this);
                        this.parent._setChildrenIndices();
                        return true;
                  Severity: Major
                  Found in src/Node.ts and 1 other location - About 1 hr to fix
                  src/Node.ts on lines 1361..1366

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

                  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 clone has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    clone(obj?: any) {
                      // instantiate new node
                      var attrs = Util.cloneObject(this.attrs),
                        key,
                        allListeners,
                  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

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

                      if (children.length > 1) {
                        for (var i = 0; i < children.length; i++) {
                          this.add(children[i]);
                        }
                        return this;
                  Severity: Major
                  Found in src/Container.ts and 1 other location - About 1 hr to fix
                  src/Stage.ts on lines 403..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 60.

                  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