packages/nerv/src/lifecycle.ts

Summary

Maintainability
D
1 day
Test Coverage

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'
Severity: Minor
Found in packages/nerv/src/lifecycle.ts - About 3 hrs to fix

    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()
    Severity: Minor
    Found in packages/nerv/src/lifecycle.ts - About 3 hrs 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 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()
    Severity: Major
    Found in packages/nerv/src/lifecycle.ts - About 2 hrs to fix

      Function mountComponent has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function mountComponent (
        vnode: FullComponent,
        parentContext: ParentContext,
        parentComponent
      ) {
      Severity: Minor
      Found in packages/nerv/src/lifecycle.ts - About 1 hr to fix

        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
        Severity: Minor
        Found in packages/nerv/src/lifecycle.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 mountComponent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function mountComponent (
          vnode: FullComponent,
          parentContext: ParentContext,
          parentComponent
        ) {
        Severity: Minor
        Found in packages/nerv/src/lifecycle.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 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()
        Severity: Minor
        Found in packages/nerv/src/lifecycle.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