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'
Function attachEvent
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export function attachEvent (
domNode: Element,
eventName: string,
handler: Function
) {
- Read upRead up
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
) {
- Read upRead up
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
) {
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) {
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
- Read upRead up
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') {
- Read upRead up
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) {
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) {
- Read upRead up
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"