Typescript SonarQube refactor this function to reduce its Cognitive Complexity

Viewed 16

For the below Typescript function i am trying to figure out how to reduce the Cognitive Complexity.

a.Adress = stringIsNullOrEmpty(a.Adress) ? undefined : unidecode(a.Adress);


function stringIsNullOrEmpty(s: string | null | undefined): s is null | undefined {
  return s === null || s === undefined || s.trim().length === 0;
}
0 Answers
Related