spritejs/sprite-core

View on GitHub

Showing 120 of 120 total issues

Consider simplifying this complex logical expression.
Open

  if('fontSize' in attrs
    || 'fontFamily' in attrs
    || 'fontStyle' in attrs
    || 'fontVariant' in attrs
    || 'fontWeight' in attrs) {
Severity: Critical
Found in src/modules/css/stylesheet.js - About 2 hrs to fix

    Function dispatchEvent has 83 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      dispatchEvent(type, evt, collisionState = false, swallow = false, useCapturePhase = null) { // eslint-disable-line complexity
        const handlers = this.getEventHandlers(type);
        if(swallow && handlers.length === 0) {
          return;
        }
    Severity: Major
    Found in src/core/layer.js - About 2 hrs to fix

      Function dispatchEvent has 82 lines of code (exceeds 50 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: Major
      Found in src/core/basenode.js - About 2 hrs to fix

        Function computeStyle has 81 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

          computeStyle(el) {
            if(!el.attributes) return {};
            el.__styleNeedUpdate = false;
            if(cssRules.length <= 0) return {};
            const attrs = {};
        Severity: Major
        Found in src/modules/css/stylesheet.js - About 2 hrs to fix

          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

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

                                  if(width === '') {
                                    w = boxSize[0] | 0;
                                    if(height !== '' && boxSize[1]) {
                                      w *= height / boxSize[1];
                                    }
                              Severity: Major
                              Found in src/core/sprite.js and 1 other location - About 1 hr to fix
                              src/core/sprite.js on lines 146..151

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

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

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

                                  if(height === '') {
                                    h = boxSize[1] | 0;
                                    if(width !== '' && boxSize[0]) {
                                      h *= width / boxSize[0];
                                    }
                              Severity: Major
                              Found in src/core/sprite.js and 1 other location - About 1 hr to fix
                              src/core/sprite.js on lines 140..145

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

                              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