konvajs/konva

View on GitHub

Showing 359 of 359 total issues

Function dilateMask has a Cognitive Complexity of 18 (exceeds 5 allowed). 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: Minor
Found in src/filters/Mask.ts - About 2 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 3 locations. Consider refactoring.
Open

    if (!a || a < Math.abs(c)) {
      a = c;
      s = p / 4;
    } else {
      s = (p / (2 * Math.PI)) * Math.asin(c / a);
Severity: Major
Found in src/Tween.ts and 2 other locations - About 2 hrs to fix
src/Tween.ts on lines 627..632
src/Tween.ts on lines 658..663

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

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

    if (!a || a < Math.abs(c)) {
      a = c;
      s = p / 4;
    } else {
      s = (p / (2 * Math.PI)) * Math.asin(c / a);
Severity: Major
Found in src/Tween.ts and 2 other locations - About 2 hrs to fix
src/Tween.ts on lines 627..632
src/Tween.ts on lines 687..692

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

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

    if (!a || a < Math.abs(c)) {
      a = c;
      s = p / 4;
    } else {
      s = (p / (2 * Math.PI)) * Math.asin(c / a);
Severity: Major
Found in src/Tween.ts and 2 other locations - About 2 hrs to fix
src/Tween.ts on lines 658..663
src/Tween.ts on lines 687..692

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

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 vsu = v * s * Math.cos((h * Math.PI) / 180),
    vsw = v * s * Math.sin((h * Math.PI) / 180);
Severity: Major
Found in src/filters/HSV.ts and 1 other location - About 2 hrs to fix
src/filters/HSL.ts on lines 82..83

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

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 vsu = v * s * Math.cos((h * Math.PI) / 180),
    vsw = v * s * Math.sin((h * Math.PI) / 180);
Severity: Major
Found in src/filters/HSL.ts and 1 other location - About 2 hrs to fix
src/filters/HSV.ts on lines 37..38

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

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

  drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas) {
    // basically there are 3 drawing modes
    // 1 - simple drawing when nothing is cached.
    // 2 - when we are caching current
    // 3 - when node is cached and we need to draw it into layer
Severity: Major
Found in src/Shape.ts - About 2 hrs to fix

    Function constructor has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(config: TweenConfig) {
        var that = this,
          node = config.node as any,
          nodeId = node._id,
          duration,
    Severity: Major
    Found in src/Tween.ts - About 2 hrs to fix

      Function _tweenFunc has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _tweenFunc(i) {
          var node = this.node,
            attrs = Tween.attrs[node._id][this._id],
            key,
            attr,
      Severity: Major
      Found in src/Tween.ts - About 2 hrs to fix

        Function _getCachedSceneCanvas has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _getCachedSceneCanvas() {
            var filters = this.filters(),
              cachedCanvas = this._getCanvasCache(),
              sceneCanvas = cachedCanvas.scene,
              filterCanvas = cachedCanvas.filter,
        Severity: Major
        Found in src/Node.ts - About 2 hrs to fix

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

            _setTextData() {
              const { width, height } = this._getTextSize(this.attrs.text);
              this.textWidth = width;
              this.textHeight = height;
              this.glyphInfo = [];
          Severity: Minor
          Found in src/shapes/TextPath.ts - About 2 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 _fitNodesInto has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            _fitNodesInto(newAttrs, evt?) {
              var oldAttrs = this._getNodeRect();
          
              const minSize = 1;
          
          
          Severity: Minor
          Found in src/shapes/Transformer.ts - About 2 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 Enhance has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Enhance: Filter = function (imageData) {
            var data = imageData.data,
              nSubPixels = data.length,
              rMin = data[0],
              rMax = rMin,
          Severity: Minor
          Found in src/filters/Enhance.ts - About 2 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 __getNodeRect has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            __getNodeRect() {
              var node = this.getNode();
              if (!node) {
                return {
                  x: -MAX_SAFE_INTEGER,
          Severity: Major
          Found in src/shapes/Transformer.ts - About 2 hrs to fix

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

              var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw,
                rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw,
                rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
            Severity: Major
            Found in src/filters/HSV.ts and 1 other location - About 2 hrs to fix
            src/filters/HSL.ts on lines 85..87

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

            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

              var rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw,
                rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw,
                rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
            Severity: Major
            Found in src/filters/HSL.ts and 1 other location - About 2 hrs to fix
            src/filters/HSV.ts on lines 40..42

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

            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 (typeof window !== 'undefined') {
                  window.addEventListener('mousemove', this._handleMouseMove);
                  window.addEventListener('touchmove', this._handleMouseMove);
                  window.addEventListener('mouseup', this._handleMouseUp, true);
                  window.addEventListener('touchend', this._handleMouseUp, true);
            Severity: Major
            Found in src/shapes/Transformer.ts and 1 other location - About 2 hrs to fix
            src/shapes/Transformer.ts on lines 961..966

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

            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 (typeof window !== 'undefined') {
                    window.removeEventListener('mousemove', this._handleMouseMove);
                    window.removeEventListener('touchmove', this._handleMouseMove);
                    window.removeEventListener('mouseup', this._handleMouseUp, true);
                    window.removeEventListener('touchend', this._handleMouseUp, true);
            Severity: Major
            Found in src/shapes/Transformer.ts and 1 other location - About 2 hrs to fix
            src/shapes/Transformer.ts on lines 688..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 79.

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

              _createBack() {
                var back = new Shape({
                  name: 'back',
                  width: 0,
                  height: 0,
            Severity: Major
            Found in src/shapes/Transformer.ts - About 2 hrs to fix

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

                var br = 0.299 * v - 0.3 * vsu + 1.25 * vsw,
                  bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw,
                  bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
              Severity: Major
              Found in src/filters/HSV.ts and 3 other locations - About 2 hrs to fix
              src/filters/HSL.ts on lines 88..90
              src/filters/HSL.ts on lines 91..93
              src/filters/HSV.ts on lines 43..45

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

              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