packages/nerv/src/event.ts

Summary

Maintainability
C
1 day
Test Coverage

File event.ts has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isFunction, MapClass, doc, isiOS, isIE9, isTaro } from 'nerv-utils'
import { noop } from 'nerv-shared'
import { supportedPassiveEventMap } from './passive-event'

const ONINPUT = 'oninput'
Severity: Minor
Found in packages/nerv/src/event.ts - About 3 hrs to fix

    Function attachEvent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export function attachEvent (
      domNode: Element,
      eventName: string,
      handler: Function
    ) {
    Severity: Minor
    Found in packages/nerv/src/event.ts - 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 detachEvent has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    export function detachEvent (
      domNode: Element,
      eventName: string,
      handler: Function
    ) {
    Severity: Minor
    Found in packages/nerv/src/event.ts - 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 attachEvent has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function attachEvent (
      domNode: Element,
      eventName: string,
      handler: Function
    ) {
    Severity: Minor
    Found in packages/nerv/src/event.ts - About 1 hr to fix

      Function attachEventToDocument has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function attachEventToDocument (d, eventName, delegatedRoots) {
        const eventHandler = (event) => {
          const items = delegatedRoots.items
          const count = items.size
          if (count > 0) {
      Severity: Minor
      Found in packages/nerv/src/event.ts - About 1 hr to fix

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

        function dispatchEvent (event, target, items, count, eventData) {
          const eventsToTrigger = items.get(target)
          if (eventsToTrigger) {
            count--
            eventData.currentTarget = target
        Severity: Minor
        Found in packages/nerv/src/event.ts - 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

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

        function fixEvent (node: Element, eventName: string) {
          if (isTaro && eventName === 'onClick') {
            eventName = 'onTap'
          }
          if (eventName === 'onDoubleClick') {
        Severity: Minor
        Found in packages/nerv/src/event.ts - 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 dispatchEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function dispatchEvent (event, target, items, count, eventData) {
        Severity: Minor
        Found in packages/nerv/src/event.ts - About 35 mins to fix

          Function attachEventToDocument has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function attachEventToDocument (d, eventName, delegatedRoots) {
            const eventHandler = (event) => {
              const items = delegatedRoots.items
              const count = items.size
              if (count > 0) {
          Severity: Minor
          Found in packages/nerv/src/event.ts - 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

          There are no issues that match your filters.

          Category
          Status