zingchart/zingtouch

View on GitHub

Showing 28 of 50 total issues

Function end has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  end(inputs) {
    if (this.numInputs === inputs.length) {
      let output = {
        data: [],
      };
Severity: Minor
Found in src/gestures/Swipe.js - About 5 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 move has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  move(inputs, state, element) {
    if (this.numInputs !== inputs.length) return null;

    const output = {
      data: [],
Severity: Major
Found in src/gestures/Pan.js - About 2 hrs to fix

    Function end has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      end(inputs) {
        if (this.numInputs === inputs.length) {
          let output = {
            data: [],
          };
    Severity: Major
    Found in src/gestures/Swipe.js - About 2 hrs to fix

      Function arbiter has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function arbiter(event, region) {
        const state = region.state;
        const eventType = util.normalizeEvent[ event.type ];
      
        /*
      Severity: Minor
      Found in src/core/arbiter.js - About 2 hrs to fix

        Function move has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          move(inputs, state, element) {
            const numActiveInputs = state.numActiveInputs();
            if (this.numInputs !== numActiveInputs) return null;
        
            let currentPivot, initialPivot;
        Severity: Minor
        Found in src/gestures/Rotate.js - About 1 hr to fix

          Function updateInputs has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            updateInputs(event, regionElement) {
              let eventType = (event.touches) ?
                'TouchEvent' : ((event.pointerType) ? 'PointerEvent' : 'MouseEvent');
              switch (eventType) {
                case 'TouchEvent':
          Severity: Minor
          Found in src/core/classes/State.js - About 1 hr to fix

            Function updateInputs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              updateInputs(event, regionElement) {
                let eventType = (event.touches) ?
                  'TouchEvent' : ((event.pointerType) ? 'PointerEvent' : 'MouseEvent');
                switch (eventType) {
                  case 'TouchEvent':
            Severity: Minor
            Found in src/core/classes/State.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 packData has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function packData( input, progress ) {
                  const distanceFromOrigin = util.distanceBetweenTwoPoints(
                    input.initial.x,
                    input.current.x,
                    input.initial.y,
            Severity: Minor
            Found in src/gestures/Pan.js - About 1 hr to fix

              Function end has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                end(inputs) {
                  if (inputs.length !== this.numInputs) {
                    return null;
                  }
                  let startTime = Number.MAX_VALUE;
              Severity: Minor
              Found in src/gestures/Tap.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 exports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = (env, argv) => {
                argv.mode = argv.mode || 'production';
                const plugins = [];
                const filename = (argv.mode === 'production') ? 'zingtouch.min.js' : 'zingtouch.js';
                const config = {
              Severity: Minor
              Found in webpack.config.js - About 1 hr to fix

                Function end has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  end(inputs) {
                    if (inputs.length !== this.numInputs) {
                      return null;
                    }
                    let startTime = Number.MAX_VALUE;
                Severity: Minor
                Found in src/gestures/Tap.js - About 1 hr to fix

                  Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    constructor(element, capture, preventDefault, id) {
                      /**
                       * The identifier for the Region. This is assigned by the ZingTouch object
                       * and is used to hash gesture id for uniqueness.
                       * @type {Number}
                  Severity: Minor
                  Found in src/core/classes/Region.js - About 1 hr to fix

                    Function move has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      move(inputs, state, element) {
                        if (this.numInputs === inputs.length) {
                          for (let i = 0; i < inputs.length; i++) {
                            let progress = inputs[i].getGestureProgress(this.getId());
                            if (!progress.moves) {
                    Severity: Minor
                    Found in src/gestures/Swipe.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 arbiter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function arbiter(event, region) {
                      const state = region.state;
                      const eventType = util.normalizeEvent[ event.type ];
                    
                      /*
                    Severity: Minor
                    Found in src/core/arbiter.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 addBinding has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      addBinding(element, gesture, handler, capture, bindOnce) {
                        let boundGesture;
                    
                        // Error type checking.
                        if (element && typeof element.tagName === 'undefined') {
                    Severity: Minor
                    Found in src/core/classes/State.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 move has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      move(inputs, state, element) {
                        if (state.numActiveInputs() === DEFAULT_INPUTS) {
                          const currentDistance = util.distanceBetweenTwoPoints(
                            inputs[0].current.x,
                            inputs[1].current.x,
                    Severity: Minor
                    Found in src/gestures/Distance.js - About 1 hr to fix

                      Function constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        constructor(options) {
                          super();
                          /**
                           * The type of the Gesture
                           * @type {String}
                      Severity: Minor
                      Found in src/gestures/Swipe.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

                      Avoid deeply nested control flow statements.
                      Open

                                  if (progress.moves[index].time !== currentMove.time) {
                                    lastMove = progress.moves[index];
                                    break;
                                  }
                      Severity: Major
                      Found in src/gestures/Swipe.js - About 45 mins to fix

                        Function getVelocity has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          getVelocity(startX, startY, startTime, endX, endY, endTime) {
                        Severity: Minor
                        Found in src/core/util.js - About 45 mins to fix

                          Function isWithin has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            isWithin(currentX, currentY, previousX, previousY, tolerance) {
                          Severity: Minor
                          Found in src/core/util.js - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language