NOSONAR for Cognitive Complexity

I have a function that has a cognitive complexity error. And for some reason, the code has to be the way it is and it shouldn’t give a sonarqube failure.
I tried using // NOSONAR after the function (end of the line) which is giving me a cognitive complexity error that excluded my function from sonarqube scan.

func Myfunc() nil { // NOSONAR
// code
}

Hi,

Welcome to the community!

I’ve moved your post because the thread you initially posted this in was over a year old and only tangentially related, at best. Per the FAQ if a topic is more than two months old, even if your content is directly related, you should create a new thread. Please don’t resurrect old threads.

The topic you posted in had “Go” in the title. Does that mean that you’re also asking about Go? Because //NOSONAR is implemented on a language-by-language basis, and I believe we made the decision not to implement it in any new languages.

You should simply mark your Cognitive Complexity issue as Won’t Fix (or Accepted if you’ve already adopted SonarQube 10.4).

 
Ann