RubyLouvre/anu

View on GitHub
packages/render/dom/event.js

Summary

Maintainability
D
2 days
Test Coverage

File event.js has 356 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { document, modern, contains } from './browser';
import { isFn, noop, toLowerCase } from 'react-core/util';
import { Renderer } from 'react-core/createRenderer';
import { enqueueDuplex } from './duplex';
export let rform = /textarea|input|select|option/i;
Severity: Minor
Found in packages/render/dom/event.js - About 4 hrs to fix

    Function collectPaths has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    function collectPaths(begin, end, unique) {
        let paths = [];
        let node = begin;
        //先判定路径上有绑定事件没有
        while (node && node.nodeType == 1) {
    Severity: Minor
    Found in packages/render/dom/event.js - About 4 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 blurFocus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function blurFocus(e) {
        let dom = getTarget(e);
        let type = focusMap[e.type];
        if (Renderer.inserting) {
            if (type === 'blur') {
    Severity: Minor
    Found in packages/render/dom/event.js - 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 collectPaths has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function collectPaths(begin, end, unique) {
        let paths = [];
        let node = begin;
        //先判定路径上有绑定事件没有
        while (node && node.nodeType == 1) {
    Severity: Minor
    Found in packages/render/dom/event.js - About 1 hr to fix

      Function wheel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      eventPropHooks.wheel = function(event) {
          event.deltaX =
              'deltaX' in event
                  ? event.deltaX
                  : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
      Severity: Minor
      Found in packages/render/dom/event.js - About 55 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 (!node) {
                              break inner;
                          }
      Severity: Major
      Found in packages/render/dom/event.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (node.__events && !unique[uid]) {
                                unique[uid] = 1;
                                paths.push({ node, events: node.__events });
                            }
        Severity: Major
        Found in packages/render/dom/event.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if (node === end) {
                                  return paths;
                              }
          Severity: Major
          Found in packages/render/dom/event.js - About 45 mins to fix

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

            export function eventAction(dom, name, val, lastProps, fiber) {
                let events = dom.__events || (dom.__events = {});
                events.vnode = fiber;
                let refName = toLowerCase(name.slice(2));
                if (val === false) {
            Severity: Minor
            Found in packages/render/dom/event.js - 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 eventAction has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function eventAction(dom, name, val, lastProps, fiber) {
            Severity: Minor
            Found in packages/render/dom/event.js - About 35 mins to fix

              Function getLowestCommonAncestor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function getLowestCommonAncestor(instA, instB) {
                  let depthA = 0;
                  for (let tempA = instA; tempA; tempA = tempA.parentNode) {
                      depthA++;
                  }
              Severity: Minor
              Found in packages/render/dom/event.js - 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 triggerEventFlow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function triggerEventFlow(paths, prop, e) {
                  for (let i = paths.length; i--; ) {
                      let path = paths[i];
                      let fn = path.events[prop];
                      if (isFn(fn)) {
              Severity: Minor
              Found in packages/render/dom/event.js - 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