Showing 341 of 341 total issues

Avoid deeply nested control flow statements.
Open

        } else if (prop === 'defaultChecked') {
          if (!props.checked) {
            renderedString += ` checked="${value}"`
          }
        } else if (isSvg && prop.match(/^xlink\:?(.+)/)) {
Severity: Major
Found in packages/nerv-server/src/index.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (self.parentNode == null) {
                          div.appendChild(self);
                        }
    Severity: Major
    Found in browsers/polyfill.js - About 45 mins to fix

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

        attach (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

      Avoid deeply nested control flow statements.
      Open

            } else if (patched !== bLeft) {
              for (i = bLeft - 1; i >= 0; i--) {
                if (sources[i] === -1) {
                  pos = i + bStart
                  node = b[pos]
      Severity: Major
      Found in packages/nerv/src/vdom/patch.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                for (i = bLeft - 1; i >= 0; i--) {
                  if (sources[i] === -1) {
                    pos = i + bStart
                    node = b[pos]
                    nextPos = pos + 1
        Severity: Major
        Found in packages/nerv/src/vdom/patch.ts - About 45 mins to fix

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

          export function getData (_vnode) {
            const vnode = _vnode instanceof Component ? _vnode.vnode : _vnode
            const component = vnode.component
            let updater: any = null
          
          
          Severity: Minor
          Found in packages/nerv-devtools/src/utils.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 constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            constructor (type, props) {
              this.type = type
              this.name = type.name
              if (isUndefined(this.name)) {
                const names = type.toString().match(/^function\s*([^\s(]+)/)
          Severity: Minor
          Found in packages/nerv/src/full-component.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 (aNode !== null) {
                    unmount(aNode, dom)
                    i--
                  }
          Severity: Major
          Found in packages/nerv/src/vdom/patch.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if ((attr = self.getAttribute(ontype))) {
                                  removeAttribute.call(self, ontype);
                                }
            Severity: Major
            Found in browsers/polyfill.js - About 45 mins to fix

              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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          ;[div, div2].forEach(el => {
                            expect(el.namespaceURI).toBe('http://www.w3.org/1999/xhtml')
                            // DOM tagName is capitalized by browsers.
                            expect(el.tagName).toBe('DIV')
                          })
                      Severity: Minor
                      Found in packages/nerv/__tests__/svg.spec.js and 1 other location - About 45 mins to fix
                      packages/nerv/__tests__/svg.spec.js on lines 199..203

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 50.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                            const Test = sinon.spy(({ foo, children }) => (
                              <div foo={foo}>{children}</div>
                            ))
                      Severity: Minor
                      Found in packages/nerv-server/__tests__/render.spec.js and 1 other location - About 45 mins to fix
                      packages/nerv-server/__tests__/render.spec.js on lines 99..101

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 50.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language