zingchart/zingtouch

View on GitHub

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

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

                    const centerPoint = util.getMidpoint(
                      inputs[0].current.x,
                      inputs[1].current.x,
                      inputs[0].current.y,
                      inputs[1].current.y);
              Severity: Major
              Found in src/gestures/Distance.js and 1 other location - About 1 hr to fix
              src/gestures/Distance.js on lines 92..96

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

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

                    const currentDistance = util.distanceBetweenTwoPoints(
                      inputs[0].current.x,
                      inputs[1].current.x,
                      inputs[0].current.y,
                      inputs[1].current.y);
              Severity: Major
              Found in src/gestures/Distance.js and 1 other location - About 1 hr to fix
              src/gestures/Distance.js on lines 97..101

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

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

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

                      progress.lastEmittedDistance = util.distanceBetweenTwoPoints(
                        inputs[0].current.x,
                        inputs[1].current.x,
                        inputs[0].current.y,
                        inputs[1].current.y);
                Severity: Major
                Found in src/gestures/Distance.js and 1 other location - About 1 hr to fix
                src/gestures/Rotate.js on lines 75..79

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

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

                      currentPivot = util.getMidpoint(
                        inputs[0].current.x,
                        inputs[1].current.x,
                        inputs[0].current.y,
                        inputs[1].current.y);
                Severity: Major
                Found in src/gestures/Rotate.js and 1 other location - About 1 hr to fix
                src/gestures/Distance.js on lines 70..74

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

                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 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 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 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 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
                      Severity
                      Category
                      Status
                      Source
                      Language