Showing Cognitive Complexity error for the below code without hint. Can somebody help me on this?
let titleSize: any = "h4",
descriptionSize: any = "body1";
if (mobileDevice) {
titleSize = "h5";
descriptionSize = "body2";
}

Showing Cognitive Complexity error for the below code without hint. Can somebody help me on this?
let titleSize: any = "h4",
descriptionSize: any = "body1";
if (mobileDevice) {
titleSize = "h5";
descriptionSize = "body2";
}

Hi,
Welcome to the community!
Could you show the entire code / issue?
And I guess you’re asking for hints on refactoring to reduce the Cognitive Complexity?
Ann
Hi,
Cognitive Complexity issues are raised when the overall complexity of a method/function is above the configured threshold, which is 15 by default.
Those secondary locations are showing you that lines 187, 191, and 195 contribute to the funciton’s cumulative complexity. And they don’t strike me as immediate candidates for refactoring. If you’d like to share the entire method, I’ll be happy to take a look and make recommendations for any possible refactoring I see.
Ann