spritejs/sprite-core

View on GitHub

Showing 86 of 120 total issues

Function attr has a Cognitive Complexity of 29 (exceeds 25 allowed). Consider refactoring.
Open

  attr(props, val) {
    const setVal = (key, value) => {
      if(!(key in this[_attr])) {
        createAttribute(this[_attr], key);
      }
Severity: Minor
Found in src/core/basenode.js - About 55 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 drawBgImage has a Cognitive Complexity of 29 (exceeds 25 allowed). Consider refactoring.
Open

function drawBgImage(drawingContext, bgimage, borderWidth, offsetWidth, offsetHeight, clientWidth, clientHeight) {
  const {image, display, clip9} = bgimage;

  if(display === '.9') {
    drawDot9Image(drawingContext, image, clip9, borderWidth, offsetWidth, offsetHeight, clientWidth, clientHeight);
Severity: Minor
Found in src/core/basesprite.js - About 55 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 drawDot9Image has 8 arguments (exceeds 5 allowed). Consider refactoring.
Open

function drawDot9Image(drawingContext, image, clip9, borderWidth, offsetWidth, offsetHeight, clientWidth, clientHeight) {
Severity: Major
Found in src/core/basesprite.js - About 50 mins to fix

    Function enter has a Cognitive Complexity of 28 (exceeds 25 allowed). Consider refactoring.
    Open

      enter(toState) {
        const states = this.attr('states');
        let ret;
        if(states && (states.beforeEnter || states.afterEnter)) {
          const deferred = this.resolveStates(['beforeEnter', 'afterEnter'], (_states) => {
    Severity: Minor
    Found in src/modules/actions/node.js - 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(subject[_attrAbsolute]) {
                  return pv * ret.v;
                }
    Severity: Major
    Found in src/utils/decorators.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

            if(name === 'class') {
              ret = `.${value}`;
            } else {
              ret = `[${name}~="${value}"]`;
            }
      Severity: Major
      Found in src/modules/css/stylesheet.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

            } else if(action === 'any') {
              ret = `[${name}*="${value}"]`;
            } else if(action === 'hyphen') {
              ret = `[${name}|="${value}"]`;
            }
        Severity: Major
        Found in src/modules/css/stylesheet.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if(node.querySelectorAll) {
                        const nodes = node.querySelectorAll('*');
                        nodes.forEach(child => child.restyle());
                      }
          Severity: Major
          Found in src/core/basenode.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if(pv !== ret.pv) {
                          this[key] = ret.rv;
                          return this[key];
                        }
            Severity: Major
            Found in src/utils/decorators.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if(subject[_attrAbsolute]) {
                            return pv * ret.v;
                          }
              Severity: Major
              Found in src/utils/decorators.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                    if(d <= w) {
                      ret = [x, y + h, x + d, y];
                    } else {
                      d = w / tan;
                      ret = [x, y + h, x + w, y + h - d];
                Severity: Major
                Found in src/utils/render.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if(touch.identifier === identifier) {
                                const targets = this.layer.touchedTargets[identifier];
                                if(targets) {
                                  targets.forEach((target) => {
                                    if(target !== this && target.layer === this) {
                  Severity: Major
                  Found in src/core/layer.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                for(let i = 0; i < sprites.length; i++) {
                                  const sprite = sprites[i];
                                  const hit = sprite.dispatchEvent(type, evt, collisionState, swallow, useCapturePhase);
                                  if(hit) {
                                    if(evt.targetSprites) {
                    Severity: Major
                    Found in src/core/layer.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                              } else if(key === 'transitionDelay') {
                                transition = transition || {};
                                transition.delay = value;
                              } else if(key === 'transitionDuration') {
                                transition = transition || {};
                      Severity: Major
                      Found in src/modules/css/stylesheet.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  while(ch > borderWidth) {
                                    drawingContext.drawImage(image, clientWidth - cw, clientHeight - ch, w, h);
                                    ch -= h;
                                  }
                        Severity: Major
                        Found in src/core/basesprite.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                if(unit === 'vmax') {
                                  size *= Math.max(width, height) / 100;
                                } else {
                                  size *= Math.min(width, height) / 100;
                                }
                          Severity: Major
                          Found in src/utils/utils.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if(/Color$/.test(key)) {
                                        attrs.borderColor = value;
                                      } else if(/Style$/.test(key)) {
                                        attrs.borderStyle = value;
                                      } else if(/Width$/.test(key)) {
                            Severity: Major
                            Found in src/modules/css/stylesheet.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if(hit) {
                                            if(evt.targetSprites) {
                                              targetSprites.push(...evt.targetSprites);
                                              delete evt.targetSprites;
                                            }
                              Severity: Major
                              Found in src/core/group.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if(layer) {
                                              if(relative === 'rw') {
                                                pv = layer.resolution[0];
                                              } else if(relative === 'rh') {
                                                pv = layer.resolution[1];
                                Severity: Major
                                Found in src/utils/decorators.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if(!evt.target) evt.target = this.getTargetFromXY(evt.parentX, evt.parentY);
                                  Severity: Major
                                  Found in src/core/layer.js - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language