I have a function and if statement as below. How I can lower the cognitive complexity?
const renderInput = (element, a) => {
return (
<Input
key={a}
name={element.label ? element.label : ''}// Cognitive Complexity
type={element.type ? element.type : ''}// Cognitive Complexity
label={element.label ? element.label : ''}// Cognitive Complexity
/>
)
}
const renderTag = (element, a) => {
if (element.element === 'input' ) { // Cognitive Complexity
if (element.type === 'submit' ) { // Cognitive Complexity
return testFunction1()
}
if (element.type !== 'file') { // Cognitive Complexity
return testFunction2()
}
}
}