konvajs/konva

View on GitHub

Showing 359 of 359 total issues

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

    if (index < len - 1) {
      this.parent.children.splice(index, 1);
      this.parent.children.push(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 1422..1427

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

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

    if (arguments.length > 1) {
      for (var i = 0; i < arguments.length; i++) {
        this.add(arguments[i]);
      }
      return this;
Severity: Major
Found in src/Stage.ts and 1 other location - About 1 hr to fix
src/Container.ts on lines 130..135

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

  __getFillPattern() {
    if (this.fillPatternImage()) {
      var ctx = getDummyContext();
      const pattern = ctx.createPattern(
        this.fillPatternImage(),
Severity: Minor
Found in src/Shape.ts - About 1 hr to fix

    Function _toKonvaCanvas has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _toKonvaCanvas(config) {
        config = config || {};
    
        var box = this.getClientRect();
    
    
    Severity: Minor
    Found in src/Node.ts - About 1 hr to fix

      Function _proxyDrag has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _proxyDrag(node: Node) {
          let lastPos;
          node.on(`dragstart.${this._getEventNamespace()}`, (e) => {
            lastPos = node.getAbsolutePosition();
            // actual dragging of Transformer doesn't make sense
      Severity: Minor
      Found in src/shapes/Transformer.ts - About 1 hr to fix

        Function _runFrames has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static _runFrames() {
            const layerHash = {};
            const animations = this.animations;
            /*
             * loop through all animations and execute animation
        Severity: Minor
        Found in src/Animation.ts - About 1 hr to fix

          Function _endDragBefore has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _endDragBefore(evt?) {
              const drawNodes: Array<Container> = [];
              DD._dragElements.forEach((elem) => {
                const { node } = elem;
                // we need to find pointer relative to that node
          Severity: Minor
          Found in src/DragAndDrop.ts - About 1 hr to fix

            Function toObject has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              toObject() {
                var attrs = this.getAttrs() as any,
                  key,
                  val,
                  getter,
            Severity: Minor
            Found in src/Node.ts - About 1 hr to fix

              Function _fireAndBubble has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _fireAndBubble(eventType, evt, compareShape?) {
                  if (evt && this.nodeType === SHAPE) {
                    evt.target = this;
                  }
              
              
              Severity: Minor
              Found in src/Node.ts - About 1 hr to fix

                Function off has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  off(evtStr?: string, callback?: Function) {
                    var events = (evtStr || '').split(SPACE),
                      len = events.length,
                      n,
                      t,
                Severity: Minor
                Found in src/Node.ts - About 1 hr to fix

                  Function _fill has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _fill(shape) {
                      const hasColor = shape.fill(),
                        fillPriority = shape.getFillPriority();
                  
                      // priority fills
                  Severity: Minor
                  Found in src/Context.ts - About 1 hr to fix

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

                      _fillLinearGradient(shape: Shape) {
                        var grd = shape._getLinearGradient();
                    
                        if (grd) {
                          this.setAttr('fillStyle', grd);
                    Severity: Major
                    Found in src/Context.ts and 1 other location - About 1 hr to fix
                    src/Context.ts on lines 830..836

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

                    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

                      _fillRadialGradient(shape: Shape) {
                        const grd = shape._getRadialGradient();
                        if (grd) {
                          this.setAttr('fillStyle', grd);
                          shape._fillFunc(this);
                    Severity: Major
                    Found in src/Context.ts and 1 other location - About 1 hr to fix
                    src/Context.ts on lines 822..829

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

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

                      _toKonvaCanvas(config) {
                        config = config || {};
                    
                        config.x = config.x || 0;
                        config.y = config.y || 0;
                    Severity: Minor
                    Found in src/Stage.ts - About 1 hr to fix

                      Function HSL has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Function getAbsoluteZIndex has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          getAbsoluteZIndex() {
                            var depth = this.getDepth(),
                              that = this,
                              index = 0,
                              nodes,
                        Severity: Minor
                        Found in src/Node.ts - About 1 hr to fix

                          Function getNumberArrayValidator has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function getNumberArrayValidator() {
                            if (Konva.isUnminified) {
                              return function (val: any, attr: string) {
                                // Retrieve TypedArray constructor as found in MDN (if TypedArray is available)
                                // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
                          Severity: Minor
                          Found in src/Validators.ts - About 1 hr to fix

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

                                if (!triggeredOnShape) {
                                  this._fire(events.pointermove, {
                                    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 741..748

                            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

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

                                    a *
                                    Math.pow(2, 10 * (t -= 1)) *
                                    Math.sin(((t * d - s) * (2 * Math.PI)) / p)
                            Severity: Major
                            Found in src/Tween.ts and 1 other location - About 1 hr to fix
                            src/Tween.ts on lines 696..698

                            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

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

                                      (a *
                                        Math.pow(2, 10 * (t -= 1)) *
                                        Math.sin(((t * d - s) * (2 * Math.PI)) / p)) +
                            Severity: Major
                            Found in src/Tween.ts and 1 other location - About 1 hr to fix
                            src/Tween.ts on lines 635..637

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language