spritejs/sprite-core

View on GitHub

Showing 86 of 120 total issues

File baseattr.js has 356 lines of code (exceeds 350 allowed). Consider refactoring.
Open

import SvgPath from 'svg-path-to-canvas';
import {Matrix} from 'sprite-math';
import NodeAttr from './attr';
import {parseColorString, oneOrTwoValues, fourValuesShortCut, eightValuesShortCut,
  parseStringInt, parseStringFloat, parseStringTransform,
Severity: Minor
Found in src/core/baseattr.js - About 2 hrs to fix

    Function resolveStates has 77 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      resolveStates(states, before, after) {
        let currentAnimation = null,
          resolved = false;
    
        const _states = [];
    Severity: Major
    Found in src/modules/actions/node.js - About 2 hrs to fix

      Function render has 75 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

        render(t, drawingContext) {
          super.render(t, drawingContext);
      
          const textAlign = this.attr('textAlign'),
            flexible = this.attr('flexible'),
      Severity: Major
      Found in src/core/label.js - About 2 hrs to fix

        Function draw has 75 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

          draw(t, drawingContext = this.context) { // eslint-disable-line complexity
            super.draw(t, drawingContext);
        
            if(!this.isVisible()) {
              return;
        Severity: Major
        Found in src/core/basesprite.js - About 2 hrs to fix

          Function enter has 74 lines of code (exceeds 50 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: Major
          Found in src/modules/actions/node.js - About 1 hr to fix

            Function relayout has 70 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            export function relayout(containerSprite, itemsSprite) {
              itemsSprite.sort((a, b) => {
                const orderA = a.attributes.order | 0,
                  orderB = b.attributes.order | 0;
                if(orderA !== orderB) {
            Severity: Major
            Found in src/modules/layout/flex.js - About 1 hr to fix

              Function draw has a Cognitive Complexity of 34 (exceeds 25 allowed). Consider refactoring.
              Open

                draw(t, drawingContext = this.context) { // eslint-disable-line complexity
                  super.draw(t, drawingContext);
              
                  if(!this.isVisible()) {
                    return;
              Severity: Minor
              Found in src/core/basesprite.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 drawDot9Image has 67 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              function drawDot9Image(drawingContext, image, clip9, borderWidth, offsetWidth, offsetHeight, clientWidth, clientHeight) {
                const w = image.width,
                  h = image.height;
              
                const [top, right, bottom, left] = clip9 || [16, 16, 16, 16];
              Severity: Major
              Found in src/core/basesprite.js - About 1 hr to fix

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

                  dispatchEvent(type, evt, collisionState = false, swallow = false, useCapturePhase = null) { // eslint-disable-line complexity
                    let handlers = this.getEventHandlers(type);
                    if(this.children && useCapturePhase === true) handlers = handlers.filter(handler => handler.useCapture);
                    if(this.children && useCapturePhase === false) handlers = handlers.filter(handler => !handler.useCapture);
                    evt.returnValue = true;
                Severity: Minor
                Found in src/core/basenode.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 dispatchEvent has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                  dispatchEvent(type, evt, collisionState = false, swallow = false, useCapturePhase = null) {
                    const handlers = this.getEventHandlers(type);
                    if(swallow && handlers.length === 0) {
                      return;
                    }
                Severity: Major
                Found in src/core/group.js - About 1 hr to fix

                  Function render has 60 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                    render(t, drawingContext) {
                      super.render(t, drawingContext);
                      const d = this.attr('d'),
                        lineWidth = this.attr('lineWidth'),
                        lineCap = this.attr('lineCap'),
                  Severity: Major
                  Found in src/core/path.js - About 1 hr to fix

                    Function calculTextboxSize has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    function calculTextboxSize(node) {
                      if(!node.context) return '';
                      const text = node.text,
                        font = node.attr('font'),
                        lineHeight = node.attr('lineHeight'),
                    Severity: Major
                    Found in src/core/label.js - About 1 hr to fix

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

                      export function sizeToPixel(value, defaultWidth) { // eslint-disable-line complexity
                        if(typeof value === 'string') {
                          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]};
                      Severity: Minor
                      Found in src/utils/utils.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 applyRative has a Cognitive Complexity of 31 (exceeds 25 allowed). Consider refactoring.
                      Open

                      function applyRative(elementDescriptor, type) {
                        const {descriptor} = elementDescriptor;
                      
                        const setter = descriptor.set;
                      
                      
                      Severity: Minor
                      Found in src/utils/decorators.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 transition has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

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

                        Function _split has 10 arguments (exceeds 5 allowed). Consider refactoring.
                        Open

                        function _split(x1, y1, x2, y2, x3, y3, x4, y4, t, reverse) {
                        Severity: Major
                        Found in src/modules/animation/patheffect/index.js - About 1 hr to fix

                          Function render has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                            render(t, drawingContext) {
                              const border = this.attr('border'),
                                borderRadius = this.attr('borderRadius'),
                                padding = this.attr('padding'),
                                [offsetWidth, offsetHeight] = this.offsetSize,
                          Severity: Major
                          Found in src/core/basesprite.js - About 1 hr to fix

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

                              fromDocumentCSS(stylesheets, override) /* istanbul ignore next */ {
                                if(override) {
                                  cssRules = cssRules.filter(r => !r.fromDoc);
                                }
                                if(typeof document === 'undefined') return;
                            Severity: Minor
                            Found in src/modules/css/stylesheet.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((key === 'font'
                                    || key === 'lineHeight'
                                    || key === 'lineBreak'
                                    || key === 'wordBreak'
                                    || key === 'letterSpacing'
                            Severity: Major
                            Found in src/core/basenode.js - About 1 hr to fix

                              Function split has 9 arguments (exceeds 5 allowed). Consider refactoring.
                              Open

                              function split(x1, y1, x2, y2, x3, y3, x4, y4, t) {
                              Severity: Major
                              Found in src/modules/animation/patheffect/index.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language