konvajs/konva

View on GitHub

Showing 354 of 354 total issues

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

        var comparePoint = centeredScaling
          ? {
              x: this.width() / 2,
              y: this.height() / 2,
            }
Severity: Major
Found in src/shapes/Transformer.ts and 3 other locations - About 2 hrs to fix
src/shapes/Transformer.ts on lines 770..778
src/shapes/Transformer.ts on lines 834..842
src/shapes/Transformer.ts on lines 868..876

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

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 comparePoint = centeredScaling
          ? {
              x: this.width() / 2,
              y: this.height() / 2,
            }
Severity: Major
Found in src/shapes/Transformer.ts and 3 other locations - About 2 hrs to fix
src/shapes/Transformer.ts on lines 770..778
src/shapes/Transformer.ts on lines 798..806
src/shapes/Transformer.ts on lines 868..876

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

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

  destroyChildren() {
    this.getChildren().forEach((child) => {
      // reset parent to prevent many _setChildrenIndices calls
      child.parent = null;
      child.index = 0;
Severity: Major
Found in src/Container.ts and 1 other location - About 2 hrs to fix
src/Container.ts on lines 82..93

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

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

export const Kaleidoscope: Filter = function (imageData) {
  var xSize = imageData.width,
    ySize = imageData.height;

  var x, y, xoff, i, r, g, b, a, srcPos, dstPos;
Severity: Major
Found in src/filters/Kaleidoscope.ts - About 2 hrs to fix

    Function _hslColorToRGBA has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      _hslColorToRGBA(str: string) {
        // Check hsl() format
        if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(str)) {
          // Extract h, s, l
          const [_, ...hsl] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(str)!;
    Severity: Minor
    Found in src/Util.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 2 locations. Consider refactoring.
    Open

    export function getFunctionValidator() {
      if (Konva.isUnminified) {
        return function (val: any, attr: string) {
          if (!Util._isFunction(val)) {
            Util.warn(
    Severity: Major
    Found in src/Validators.ts and 1 other location - About 2 hrs to fix
    src/Validators.ts on lines 91..105

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

    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

    export function getStringValidator() {
      if (Konva.isUnminified) {
        return function (val: any, attr: string) {
          if (!Util._isString(val)) {
            Util.warn(
    Severity: Major
    Found in src/Validators.ts and 1 other location - About 2 hrs to fix
    src/Validators.ts on lines 127..141

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

    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 19 (exceeds 5 allowed). Consider refactoring.
    Open

      _sceneFunc(context: Context) {
        var points = this.points(),
          length = points.length,
          tension = this.tension(),
          closed = this.closed(),
    Severity: Minor
    Found in src/shapes/Line.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 _fireAndBubble has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      _fireAndBubble(eventType, evt, compareShape?) {
        if (evt && this.nodeType === SHAPE) {
          evt.target = this;
        }
    
    
    Severity: Minor
    Found in src/Node.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

    File Blur.ts has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Factory } from '../Factory';
    import { Node, Filter } from '../Node';
    import { getNumberValidator } from '../Validators';
    /*
     the Gauss filter
    Severity: Minor
    Found in src/filters/Blur.ts - About 2 hrs to fix

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

            Array.prototype.forEach.call(evt.touches, (touch: any) => {
              this._pointerPositions.push({
                id: touch.identifier,
                x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,
                y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,
      Severity: Major
      Found in src/Stage.ts and 1 other location - About 2 hrs to fix
      src/Stage.ts on lines 842..848

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

      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

              (touch: any) => {
                this._changedPointerPositions.push({
                  id: touch.identifier,
                  x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,
                  y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,
      Severity: Major
      Found in src/Stage.ts and 1 other location - About 2 hrs to fix
      src/Stage.ts on lines 832..838

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

      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

      Factory.addGetterSetter(Node, 'green', 0, function (this: Node, val) {
        this._filterUpToDate = false;
        if (val > 255) {
          return 255;
        } else if (val < 0) {
      Severity: Major
      Found in src/filters/RGB.ts and 1 other location - About 2 hrs to fix
      src/filters/RGBA.ts on lines 58..67

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

      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

      Factory.addGetterSetter(Node, 'green', 0, function (this: Node, val) {
        this._filterUpToDate = false;
        if (val > 255) {
          return 255;
        } else if (val < 0) {
      Severity: Major
      Found in src/filters/RGBA.ts and 1 other location - About 2 hrs to fix
      src/filters/RGB.ts on lines 57..66

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

      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

        _isVisible(relativeTo?: Node): boolean {
          const visible = this.visible();
          if (!visible) {
            return false;
          }
      Severity: Major
      Found in src/Node.ts and 1 other location - About 2 hrs to fix
      src/Node.ts on lines 974..985

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

      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

        _isListening(relativeTo?: Node): boolean {
          const listening = this.listening();
          if (!listening) {
            return false;
          }
      Severity: Major
      Found in src/Node.ts and 1 other location - About 2 hrs to fix
      src/Node.ts on lines 1003..1014

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

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

        getClientRect(
          config: {
            skipTransform?: boolean;
            skipShadow?: boolean;
            skipStroke?: boolean;
      Severity: Major
      Found in src/Container.ts - About 2 hrs to fix

        Function _sceneFunc has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _sceneFunc(context: Context) {
            var points = this.points(),
              length = points.length,
              tension = this.tension(),
              closed = this.closed(),
        Severity: Major
        Found in src/shapes/Line.ts - About 2 hrs to fix

          Function _pointermove has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _pointermove(evt: TouchEvent | MouseEvent | PointerEvent) {
              const events = getEventsMap(evt.type);
              const eventType = getEventType(evt.type);
              if (!events) {
                return;
          Severity: Major
          Found in src/Stage.ts - About 2 hrs to fix

            Function erodeMask has a Cognitive Complexity of 18 (exceeds 5 allowed). 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: 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

            Severity
            Category
            Status
            Source
            Language