koraktor/gallerist

View on GitHub
assets/javascript/hammer.js

Summary

Maintainability
F
1 wk
Test Coverage

File hammer.js has 1509 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*! Hammer.JS - v2.0.7 - 2016-04-22
 * http://hammerjs.github.io/
 *
 * Copyright (c) 2016 Jorik Tangelder;
 * Licensed under the MIT license */
Severity: Major
Found in assets/javascript/hammer.js - About 4 days to fix

    Function getTouches has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getTouches(ev, type) {
        var allTouches = toArray(ev.touches);
        var targetIds = this.targetIds;
    
        // when there is only one touch, the process can be simplified
    Severity: Minor
    Found in assets/javascript/hammer.js - About 1 hr to fix

      Function process has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          process: function(input) {
              var options = this.options;
      
              var validPointers = input.pointers.length === options.pointers;
              var validMovement = input.distance < options.threshold;
      Severity: Minor
      Found in assets/javascript/hammer.js - About 1 hr to fix

        Function computeInputData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function computeInputData(manager, input) {
            var session = manager.session;
            var pointers = input.pointers;
            var pointersLength = pointers.length;
        
        
        Severity: Minor
        Found in assets/javascript/hammer.js - About 1 hr to fix

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

              handler: function PEhandler(ev) {
                  var store = this.store;
                  var removePointer = false;
          
                  var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
          Severity: Minor
          Found in assets/javascript/hammer.js - About 1 hr to fix

            Function preventDefaults has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                preventDefaults: function(input) {
                    var srcEvent = input.srcEvent;
                    var direction = input.offsetDirection;
            
                    // if the touch action did prevented once this session
            Severity: Minor
            Found in assets/javascript/hammer.js - About 1 hr to fix

              Function recognize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  recognize: function(inputData) {
                      var session = this.session;
                      if (session.stopped) {
                          return;
                      }
              Severity: Minor
              Found in assets/javascript/hammer.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                    if (source.hasOwnProperty(nextKey)) {
                                        output[nextKey] = source[nextKey];
                                    }
                Severity: Major
                Found in assets/javascript/hammer.js - About 45 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return TOUCH_ACTION_AUTO;
                  Severity: Major
                  Found in assets/javascript/hammer.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return '';
                    Severity: Major
                    Found in assets/javascript/hammer.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return '';
                      Severity: Major
                      Found in assets/javascript/hammer.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return STATE_FAILED;
                        Severity: Major
                        Found in assets/javascript/hammer.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return STATE_FAILED;
                          Severity: Major
                          Found in assets/javascript/hammer.js - About 30 mins to fix

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

                                init: function() {
                                    this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
                                    this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
                                    this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
                                },
                            Severity: Major
                            Found in assets/javascript/hammer.js and 1 other location - About 3 hrs to fix
                            assets/javascript/hammer.js on lines 457..461

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

                            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

                                destroy: function() {
                                    this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
                                    this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
                                    this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
                                }
                            Severity: Major
                            Found in assets/javascript/hammer.js and 1 other location - About 3 hrs to fix
                            assets/javascript/hammer.js on lines 448..452

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

                            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

                            function stateStr(state) {
                                if (state & STATE_CANCELLED) {
                                    return 'cancel';
                                } else if (state & STATE_ENDED) {
                                    return 'end';
                            Severity: Major
                            Found in assets/javascript/hammer.js and 1 other location - About 2 hrs to fix
                            assets/javascript/hammer.js on lines 1653..1664

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

                            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

                            function directionStr(direction) {
                                if (direction == DIRECTION_DOWN) {
                                    return 'down';
                                } else if (direction == DIRECTION_UP) {
                                    return 'up';
                            Severity: Major
                            Found in assets/javascript/hammer.js and 1 other location - About 2 hrs to fix
                            assets/javascript/hammer.js on lines 1635..1646

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

                            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

                                        } else {
                                            direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
                                            hasMoved = y != this.pY;
                                            distance = Math.abs(input.deltaY);
                                        }
                            Severity: Major
                            Found in assets/javascript/hammer.js and 1 other location - About 1 hr to fix
                            assets/javascript/hammer.js on lines 1788..1792

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

                            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

                                        if (options.direction & DIRECTION_HORIZONTAL) {
                                            direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
                                            hasMoved = x != this.pX;
                                            distance = Math.abs(input.deltaX);
                                        } else {
                            Severity: Major
                            Found in assets/javascript/hammer.js and 1 other location - About 1 hr to fix
                            assets/javascript/hammer.js on lines 1792..1796

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

                            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

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

                                var x = p2[props[0]] - p1[props[0]],
                                    y = p2[props[1]] - p1[props[1]];
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 50 mins to fix
                            assets/javascript/hammer.js on lines 733..734

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

                            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

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

                                var x = p2[props[0]] - p1[props[0]],
                                    y = p2[props[1]] - p1[props[1]];
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 50 mins to fix
                            assets/javascript/hammer.js on lines 750..751

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

                            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

                                                this._timer = setTimeoutContext(function() {
                                                    this.state = STATE_RECOGNIZED;
                                                    this.tryEmit();
                                                }, options.interval, this);
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 35 mins to fix
                            assets/javascript/hammer.js on lines 1903..1906

                            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

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

                                        this._timer = setTimeoutContext(function() {
                                            this.state = STATE_RECOGNIZED;
                                            this.tryEmit();
                                        }, options.time, this);
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 35 mins to fix
                            assets/javascript/hammer.js on lines 2103..2106

                            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

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

                            function addEventListeners(target, types, handler) {
                                each(splitStr(types), function(type) {
                                    target.addEventListener(type, handler, false);
                                });
                            }
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 35 mins to fix
                            assets/javascript/hammer.js on lines 232..236

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

                            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

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

                                    this.callback(this.manager, type, {
                                        pointers: touches[0],
                                        changedPointers: touches[1],
                                        pointerType: INPUT_TYPE_TOUCH,
                                        srcEvent: ev
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 35 mins to fix
                            assets/javascript/hammer.js on lines 1021..1026

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

                            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

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

                                    this.callback(this.manager, type, {
                                        pointers: touches[0],
                                        changedPointers: touches[1],
                                        pointerType: INPUT_TYPE_TOUCH,
                                        srcEvent: ev
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 35 mins to fix
                            assets/javascript/hammer.js on lines 966..971

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

                            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

                            function removeEventListeners(target, types, handler) {
                                each(splitStr(types), function(type) {
                                    target.removeEventListener(type, handler, false);
                                });
                            }
                            Severity: Minor
                            Found in assets/javascript/hammer.js and 1 other location - About 35 mins to fix
                            assets/javascript/hammer.js on lines 220..224

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

                            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