konvajs/konva

View on GitHub

Showing 359 of 359 total issues

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

    if (selfListeners) {
      for (var i = 0; i < selfListeners.length; i++) {
        selfListeners[i].handler.call(this, evt);
      }
    }
Severity: Minor
Found in src/Node.ts and 1 other location - About 50 mins to fix
src/Node.ts on lines 2381..2385

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

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

function _fillFuncHit(this: Node, context) {
  const fillRule = this.attrs.fillRule;
  if (fillRule) {
    context.fill(fillRule);
  } else {
Severity: Minor
Found in src/Shape.ts and 1 other location - About 50 mins to fix
src/Shape.ts on lines 120..127

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

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 m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];
Severity: Major
Found in src/Util.ts and 3 other locations - About 50 mins to fix
src/Util.ts on lines 164..164
src/Util.ts on lines 166..166
src/Util.ts on lines 167..167

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

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 y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
Severity: Minor
Found in src/shapes/Path.ts and 1 other location - About 50 mins to fix
src/shapes/Path.ts on lines 378..378

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

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 a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 getPointOnLine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  static getPointOnLine(
    dist: number,
    P1x: number,
    P1y: number,
    P2x: number,
Severity: Minor
Found in src/shapes/Path.ts - About 45 mins 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

Avoid deeply nested control flow statements.
Open

      if (keepProportion) {
        var comparePoint = centeredScaling
          ? {
              x: this.width() / 2,
              y: this.height() / 2,
Severity: Major
Found in src/shapes/Transformer.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
                var srcOff = scy * sw + scx;
                var wt = weights[cy * side + cx];
    
                a += mask[srcOff] * wt;
    Severity: Major
    Found in src/filters/Mask.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (substrWidth <= maxWidth) {
                    low = mid + 1;
                    match = substr;
                    matchWidth = substrWidth;
                  } else {
      Severity: Major
      Found in src/shapes/Text.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
                    var srcOff = scy * sw + scx;
                    var wt = weights[cy * side + cx];
        
                    a += mask[srcOff] * wt;
        Severity: Major
        Found in src/filters/Mask.ts - About 45 mins to fix

          Function ElasticEaseOut has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            ElasticEaseOut(t, b, c, d, a, p) {
          Severity: Minor
          Found in src/Tween.ts - About 45 mins to fix

            Function _getProjectionToSegment has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              _getProjectionToSegment(x1, y1, x2, y2, x3, y3) {
            Severity: Minor
            Found in src/Util.ts - About 45 mins to fix

              Function _rgbaColorToRGBA has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                _rgbaColorToRGBA(str: string) {
                  if (str.indexOf('rgba(') === 0) {
                    str = str.match(/rgba\(([^)]+)\)/)![1]!;
                    var parts = str.split(/ *, */).map((n, index) => {
                      if (n.slice(-1) === '%') {
              Severity: Minor
              Found in src/Util.ts - About 45 mins 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 ElasticEaseIn has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                ElasticEaseIn(t, b, c, d, a, p) {
              Severity: Minor
              Found in src/Tween.ts - About 45 mins to fix

                Function decompose has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  decompose() {
                    var a = this.m[0];
                    var b = this.m[1];
                    var c = this.m[2];
                    var d = this.m[3];
                Severity: Minor
                Found in src/Util.ts - About 45 mins 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 ElasticEaseInOut has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  ElasticEaseInOut(t, b, c, d, a, p) {
                Severity: Minor
                Found in src/Tween.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (shouldHandleEllipsis) {
                                this._tryToAddEllipsisToLastLine();
                                /*
                                 * stop wrapping if wrapping is disabled or if adding
                                 * one more line would overflow the fixed height
                  Severity: Major
                  Found in src/shapes/Text.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  for (var idx = ca.length - 2; idx >= 0; idx--) {
                                    if (ca[idx].command === 'M') {
                                      cpx = ca[idx].points[0] + dx;
                                      cpy = ca[idx].points[1] + dy;
                                      break;
                    Severity: Major
                    Found in src/shapes/Path.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                if (y >= height) {
                                  continue;
                                }
                      Severity: Major
                      Found in src/filters/Pixelate.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if (wrapAtWord) {
                                      // try to find a space or dash where wrapping could be done
                                      var wrapIndex;
                                      var nextChar = line[match.length];
                                      var nextIsSpaceOrDash = nextChar === SPACE || nextChar === DASH;
                        Severity: Major
                        Found in src/shapes/Text.ts - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language