File lifecycle.ts
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
// import { extend, isFunction, isNumber, isString } from 'nerv-utils'
import { extend, isFunction, isNumber, isString, clone, isUndefined, isArray } from 'nerv-utils'
import CurrentOwner from './current-owner'
import createElement from './vdom/create-element'
import createVText from './vdom/create-vtext'
Function updateComponent
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
export function updateComponent (component, isForce = false) {
let vnode = component.vnode
let dom = vnode.dom
const props = component.props
let state = component.getState()
- 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 updateComponent
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function updateComponent (component, isForce = false) {
let vnode = component.vnode
let dom = vnode.dom
const props = component.props
let state = component.getState()
Function mountComponent
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function mountComponent (
vnode: FullComponent,
parentContext: ParentContext,
parentComponent
) {
Function errorHandler
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function errorHandler (component: Component<any, any>, error) {
// if(!component) { throw error ; return }
let boundary
while (true) {
const { getDerivedStateFromError } = (component as any).constructor
- 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 mountComponent
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function mountComponent (
vnode: FullComponent,
parentContext: ParentContext,
parentComponent
) {
- 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 ensureVirtualNode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function ensureVirtualNode (rendered: any): VText | VVoid | VNode {
if (isNumber(rendered) || isString(rendered)) {
return createVText(rendered)
} else if (isInvalid(rendered)) {
return createVoid()
- 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"