spritejs/spritejs

View on GitHub

Showing 34 of 126 total issues

Function delegateEvents has 94 lines of code (exceeds 50 allowed). Consider refactoring.
Open

function delegateEvents(scene) {
  const events = ['mousedown', 'mouseup', 'mousemove', 'mousewheel', 'wheel',
    'touchstart', 'touchend', 'touchmove', 'touchcancel',
    'click', 'dblclick', 'longpress', 'tap', 'contextmenu'];

Severity: Major
Found in src/node/scene.js - About 2 hrs to fix

    File node.js has 517 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    import {mat2d} from 'gl-matrix';
    import Attr from '../attribute/node';
    import Animation from '../animation';
    import ownerDocument from '../document';
    import SpriteEvent from '../event/event';
    Severity: Major
    Found in src/node/node.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

          if(key === 'anchorX' || key === 'anchorY' || key === 'boxSizing' || key === 'width' || key === 'height' || key === 'borderWidth'
            || key === 'paddingLeft' || key === 'paddingRight' || key === 'paddingTop' || key === 'paddingBottom'
            || /^border(TopLeft|TopRight|BottomRight|BottomLeft)Radius$/.test(key)) {
            this.updateContours();
          }
      Severity: Critical
      Found in src/node/block.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

            if(key === 'text' || key === 'fontSize' || key === 'fontFamily'
              || key === 'fontStyle' || key === 'fontVariant' || key === 'fontWeight'
              || key === 'fontStretch' || key === 'lineHeight'
              || key === 'strokeColor' || key === 'fillColor'
              || key === 'strokeWidth') {
        Severity: Critical
        Found in src/node/label.js - About 2 hrs to fix

          Function transform has a Cognitive Complexity of 36 (exceeds 25 allowed). Consider refactoring.
          Open

          Severity: Minor
          Found in src/attribute/node.js - 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 updateTexture has a Cognitive Complexity of 35 (exceeds 25 allowed). Consider refactoring.
          Open

          Severity: Minor
          Found in src/node/spritesvg.js - 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 dispatchPointerEvent has 72 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          Severity: Major
          Found in src/node/spritesvg.js - About 1 hr to fix

            Function dispatchPointerEvent has 65 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

              dispatchPointerEvent(event) {
                const type = event.type;
                if(type === 'mousedown' || type === 'mouseup' || type === 'mousemove') {
                  const capturedTarget = this.__mouseCapturedTarget;
                  if(capturedTarget) {
            Severity: Major
            Found in src/node/layer.js - About 1 hr to fix

              Function sizeToPixel has a Cognitive Complexity of 33 (exceeds 25 allowed). Consider refactoring.
              Open

              export function sizeToPixel(value, defaultWidth) { // eslint-disable-line complexity
                const matched = value.trim().match(/^([\d.]+)(px|pt|pc|in|cm|mm|em|ex|rem|q|vw|vh|vmax|vmin)$/);
                if(matched) {
                  value = {size: parseFloat(matched[1]), unit: matched[2]};
                } else {
              Severity: Minor
              Found in src/utils/attribute_value.js - 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

              Consider simplifying this complex logical expression.
              Open

                  if(this[_mesh] && (key === 'strokeColor' || key === 'lineWidth' || key === 'lineCap' || key === 'lineJoin'
                    || key === 'lineDash' || key === 'lineDashOffset' || key === 'roundSegments')) {
                    const {strokeColor, lineWidth} = this.attributes;
                    if(strokeColor && lineWidth > 0) {
                      const {lineCap, lineJoin, lineDash, lineDashOffset, miterLimit, roundSegments} = this.attributes;
              Severity: Critical
              Found in src/node/path.js - About 1 hr to fix

                Function render has a Cognitive Complexity of 31 (exceeds 25 allowed). Consider refactoring.
                Open

                  render() {
                    const layers = this.orderedChildren;
                    let hostLayer = null;
                    const offscreens = [];
                
                
                Severity: Minor
                Found in src/node/scene.js - 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 updateTexture has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                Severity: Major
                Found in src/node/spritesvg.js - About 1 hr to fix

                  Function transition has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                    transition(sec, easing = 'linear') {
                      const that = this,
                        _animation = Symbol('animation');
                  
                      easing = easing || 'linear';
                  Severity: Major
                  Found in src/node/node.js - About 1 hr to fix

                    Function tick has a Cognitive Complexity of 30 (exceeds 25 allowed). Consider refactoring.
                    Open

                      tick(handler = null, {duration = Infinity, ...timelineOptions} = {}) {
                        // this._prepareRenderFinished();
                        const t = this.timeline.fork(timelineOptions);
                        const layer = this;
                    
                    
                    Severity: Minor
                    Found in src/node/layer.js - 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 contentSize has a Cognitive Complexity of 30 (exceeds 25 allowed). Consider refactoring.
                    Open

                      get contentSize() {
                        let [w, h] = super.contentSize;
                        const {width, height} = this.attributes;
                        if(width == null || height == null) {
                          const img = this.textureImage;
                    Severity: Minor
                    Found in src/node/sprite.js - 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 draw has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                      draw(meshes) {
                        super.draw(meshes);
                        const mesh = this.mesh;
                        if(mesh) {
                          const textImage = this[_textImage];
                    Severity: Major
                    Found in src/node/label.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if(!texture
                            || node[_textureContext] && node[_textureContext] !== renderer
                            || texture.image !== textureImage
                            || texture.options.repeat !== textureRepeat
                            || !compareValue(texture.options.rect, textureRect)
                      Severity: Major
                      Found in src/utils/texture.js - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                          if(ancestor instanceof Node && !enteredTargets.has(ancestor)) {
                                            enteredTargets.add(ancestor);
                                            ancestor.dispatchEvent(enterEvent);
                                          }
                        Severity: Major
                        Found in src/node/scene.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                          Severity: Major
                          Found in src/node/spritesvg.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                            Severity: Major
                            Found in src/attribute/node.js - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language