Showing 128 of 341 total issues

Avoid deeply nested control flow statements.
Open

      if (lastDom != null) {
        parentNode.replaceChild(newDom, lastDom)
      } else {
        parentNode.appendChild(newDom)
      }
Severity: Major
Found in packages/nerv/src/vdom/patch.ts - About 45 mins to fix

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

    export function createContext<T> (defaultValue: T): Context<T> {
      const contextProp = '__context_' + uid++ + '__'
    
      class Provider extends Component<ProviderProps<T>> {
        static isContextProvider = true
    Severity: Minor
    Found in packages/nerv/src/create-context.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 h has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function h (type: string, props: Props, children?: VirtualChildren) {
      let childNodes
      if (props.children) {
        if (!children) {
          children = props.children
    Severity: Minor
    Found in packages/nerv/src/vdom/h.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 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 addChildren has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function addChildren (
      childNodes: VirtualNode[],
      children: VirtualNode | VirtualNode[],
      type: string
    ) {
    Severity: Minor
    Found in packages/nerv/src/vdom/h.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

    Avoid deeply nested control flow statements.
    Open

              if (
                isValidElement(lastVnode) &&
                lastVnode.children !== EMPTY_CHILDREN
              ) {
                unmountChildren(lastVnode.children)
    Severity: Major
    Found in packages/nerv/src/vdom/patch.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (!props.value) {
                  renderedString += ` value="${encodeEntities(value)}"`
                }
      Severity: Major
      Found in packages/nerv-server/src/index.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  for (let i = 0, len = children.length; i < len; i++) {
                    const child = children[i]
                    if (isString(child)) {
                      renderedString += child === '' ? ' ' : encodeEntities(child)
                    } else if (isNumber(child)) {
        Severity: Major
        Found in packages/nerv-server/src/index.ts - About 45 mins to fix

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

            detach (vnode, ref, domNode: Element) {
              const node = isComposite(vnode) ? vnode.component : domNode
              if (isFunction(ref)) {
                const componentForCatcher = isComposite(vnode) ? vnode.component : vnode
                errorCatcher(() => {
          Severity: Minor
          Found in packages/nerv/src/vdom/ref.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 patch has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            lastVnode,
            nextVnode,
            parentNode: Element,
            context: object,
            isSvg?: boolean
          Severity: Minor
          Found in packages/nerv/src/vdom/patch.ts - About 35 mins to fix

            Function patchChildren has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              parentDom: Element,
              lastChildren,
              nextChildren,
              context: object,
              isSvg: boolean
            Severity: Minor
            Found in packages/nerv/src/vdom/patch.ts - About 35 mins to fix

              Function patchProps has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                domNode: Element,
                nextProps: Props,
                previousProps: Props,
                lastVnode: VNode,
                isSvg?: boolean
              Severity: Minor
              Found in packages/nerv/src/vdom/patch.ts - About 35 mins to fix

                Function patchArrayChildren has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  parentDom: Element,
                  lastChildren,
                  nextChildren,
                  context: object,
                  isSvg: boolean
                Severity: Minor
                Found in packages/nerv/src/vdom/patch.ts - About 35 mins to fix

                  Function mountChild has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    child: VNode,
                    domNode: Element,
                    parentContext: Object,
                    isSvg?: boolean,
                    parentComponent?
                  Severity: Minor
                  Found in packages/nerv/src/vdom/create-element.ts - About 35 mins to fix

                    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 initDevTools has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function initDevTools () {
                        const hook = (window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__
                        if (hook == null) {
                          return
                        }
                      Severity: Minor
                      Found in packages/nerv-devtools/src/index.ts - 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 transformPropsForComponent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function transformPropsForComponent (props: Props, defaultProps?: Props) {
                        const newProps: any = {}
                        for (const propName in props) {
                          const propValue = props[propName]
                          newProps[propName] = propValue
                      Severity: Minor
                      Found in packages/nerv/src/create-element.ts - 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 mountElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function mountElement (
                        element: Element | Text | Comment | Array<Element | Text | Comment>,
                        parentNode: Element,
                        refChild?: Node | null
                      ) {
                      Severity: Minor
                      Found in packages/nerv/src/vdom/create-element.ts - 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 transformPropsForRealTag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function transformPropsForRealTag (type: string, props: Props) {
                        const newProps: Props = {}
                        for (const propName in props) {
                          const propValue = props[propName]
                          if (propName === 'defaultValue') {
                      Severity: Minor
                      Found in packages/nerv/src/create-element.ts - 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

                      Avoid too many return statements within this function.
                      Open

                        return newVNode
                      Severity: Major
                      Found in packages/nerv/src/clone-element.ts - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language