RubyLouvre/avalon

View on GitHub
src/gesture/tap.js

Summary

Maintainability
B
5 hrs
Test Coverage

Function touchend has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    touchend: function(event) {
        var targetElement = tapRecognizer.element
        var now = Date.now()
            //如果是touchstart与touchend相隔太久,可以认为是长按,那么就直接返回
            //或者是在touchstart, touchmove阶段,判定其不该触发点击事件,也直接返回
Severity: Minor
Found in src/gesture/tap.js - About 1 hr to fix

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

        touchend: function(event) {
            var targetElement = tapRecognizer.element
            var now = Date.now()
                //如果是touchstart与touchend相隔太久,可以认为是长按,那么就直接返回
                //或者是在touchstart, touchmove阶段,判定其不该触发点击事件,也直接返回
    Severity: Minor
    Found in src/gesture/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 touchstart has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        touchstart: function(event) {
            //忽略多点触摸
            if (event.targetTouches.length !== 1) {
                return true
            }
    Severity: Minor
    Found in src/gesture/tap.js - About 1 hr to fix

      Function updateScrollParent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          updateScrollParent: function(targetElement) {
              //如果事件源元素位于某一个有滚动条的祖父元素中,那么保持其scrollParent与scrollTop值
              var scrollParent = targetElement.tapScrollParent
      
              if (!scrollParent || !scrollParent.contains(targetElement)) {
      Severity: Minor
      Found in src/gesture/tap.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 needClick has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          needClick: function(target) {
              //判定是否使用原生的点击事件, 否则使用sendClick方法手动触发一个人工的点击事件
              switch (target.nodeName.toLowerCase()) {
                  case 'button':
                  case 'select':
      Severity: Minor
      Found in src/gesture/tap.js - About 35 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 touchstart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          touchstart: function(event) {
              //忽略多点触摸
              if (event.targetTouches.length !== 1) {
                  return true
              }
      Severity: Minor
      Found in src/gesture/tap.js - About 35 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

      Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
      Open

      import { Recognizer } from './recognizer'
      Severity: Minor
      Found in src/gesture/tap.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      There are no issues that match your filters.

      Category
      Status