How to reduce cognitive complex in javascript event handler?

157 views Asked by At

I have some element event handler uses if statement inside, why sonar complains this if statement causes cognitive complexity? Is there a way I can avoid this or improve this?

const handleOnBlur = () => {
    if (isEditMode) {
        setMyStuff(false);
    }
};

This is counted as code smell +2, including 1 for nesting. Why if statement causes code smell especially I don't have very complex if, else or nested if statements.

Thank you!

0

There are 0 answers