spritejs/sprite-core

View on GitHub
src/modules/actions/node.js

Summary

Maintainability
D
2 days
Test Coverage

File node.js has 431 lines of code (exceeds 350 allowed). Consider refactoring.
Open

import BaseSprite from '../../core/basesprite';

function doActions(ret, target, act) {
  const actions = target.children.map(c => c[act]()).filter(d => d.promise);
  if(ret.promise) {
Severity: Minor
Found in src/modules/actions/node.js - About 3 hrs to fix

    Function exit has 111 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      exit(toState, onbyone = false) {
        const _exit = () => {
          const states = this.attr('states');
          let ret;
          const afterEnter = states.afterEnter || {};
    Severity: Major
    Found in src/modules/actions/node.js - About 3 hrs to fix

      Function _exit has 91 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

          const _exit = () => {
            const states = this.attr('states');
            let ret;
            const afterEnter = states.afterEnter || {};
            if(states && (states.beforeExit || states.afterExit)) {
      Severity: Major
      Found in src/modules/actions/node.js - About 2 hrs to fix

        Function exit has a Cognitive Complexity of 38 (exceeds 25 allowed). Consider refactoring.
        Open

          exit(toState, onbyone = false) {
            const _exit = () => {
              const states = this.attr('states');
              let ret;
              const afterEnter = states.afterEnter || {};
        Severity: Minor
        Found in src/modules/actions/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 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 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 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

            Function resolveStates has a Cognitive Complexity of 26 (exceeds 25 allowed). Consider refactoring.
            Open

              resolveStates(states, before, after) {
                let currentAnimation = null,
                  resolved = false;
            
                const _states = [];
            Severity: Minor
            Found in src/modules/actions/node.js - About 25 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

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

                      Object.keys(states.beforeEnter).forEach((key) => {
                        afterEnter[key] = this.attr(key);
                      });
            Severity: Minor
            Found in src/modules/actions/node.js and 2 other locations - About 40 mins to fix
            src/modules/actions/node.js on lines 231..233
            src/modules/actions/node.js on lines 235..237

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

            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 3 locations. Consider refactoring.
            Open

                        Object.keys(states.beforeShow).forEach((key) => {
                          beforeHide[key] = this.attr(key);
                        });
            Severity: Minor
            Found in src/modules/actions/node.js and 2 other locations - About 40 mins to fix
            src/modules/actions/node.js on lines 235..237
            src/modules/actions/node.js on lines 274..276

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

            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 3 locations. Consider refactoring.
            Open

                      Object.keys(states.hide).forEach((key) => {
                        beforeHide[key] = this.attr(key);
                      });
            Severity: Minor
            Found in src/modules/actions/node.js and 2 other locations - About 40 mins to fix
            src/modules/actions/node.js on lines 231..233
            src/modules/actions/node.js on lines 274..276

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

            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 3 locations. Consider refactoring.
            Open

            const _resolveState = Symbol('resolveState'),
              _changeStateAction = Symbol('changeStateAction'),
              _show = Symbol('show'),
              _hide = Symbol('hide'),
              _enter = Symbol('enter');
            Severity: Minor
            Found in src/modules/actions/node.js and 2 other locations - About 35 mins to fix
            src/core/attr.js on lines 3..7
            src/core/basesprite.js on lines 9..13

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

            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

            There are no issues that match your filters.

            Category
            Status