RubyLouvre/anu

View on GitHub
packages/fiber/ErrorBoundary.js

Summary

Maintainability
D
1 day
Test Coverage

Function findCatchComponent has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

function findCatchComponent(fiber, names, hook) {
    let instance,
        name,
        topFiber = fiber,
        retry,
Severity: Minor
Found in packages/fiber/ErrorBoundary.js - About 6 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 findCatchComponent has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function findCatchComponent(fiber, names, hook) {
    let instance,
        name,
        topFiber = fiber,
        retry,
Severity: Major
Found in packages/fiber/ErrorBoundary.js - About 2 hrs to fix

    Function pushError has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export function pushError(fiber, hook, error) {
        let names = [];
        let boundary = findCatchComponent(fiber, names, hook);
        let stack = describeError(names, hook);
        if (boundary) {
    Severity: Minor
    Found in packages/fiber/ErrorBoundary.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 pushError has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function pushError(fiber, hook, error) {
        let names = [];
        let boundary = findCatchComponent(fiber, names, hook);
        let stack = describeError(names, hook);
        if (boundary) {
    Severity: Minor
    Found in packages/fiber/ErrorBoundary.js - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          if (
                              hook == "componentWillUnmount" ||
                              hook == "componentDidUpdate"
                          ) {
                              boundary.effectTag = CAPTURE;
      Severity: Major
      Found in packages/fiber/ErrorBoundary.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (boundary.return.child == boundary) {
                                boundary.return.child = f;
                            }
        Severity: Major
        Found in packages/fiber/ErrorBoundary.js - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status