Ignore error checking lines in Go

SonarQube Version 2.12.2

I want to ignore lines that have the following pattern if err != nil
Since in Go we have a lot of this error checks, we are getting many Cognitive Complexity issues, and sometimes are just error checking.

Tried to use this properties, but not worked:
sonar.issue.ignore.block=rule1
sonar.issue.ignore.block.rule1.beginBlockRegexp=(?i)if err !
sonar.issue.ignore.block.rule1.endBlockRegexp=(?i)= nil

Hi,

Block exclusion is intended to keep any issues from being raised on the excluded blocks. It’s not meant to hide a few lines from a specific rule. Additionally, I believe the begin and end patterns match the entire line, although the docs aren’t explicit on that point. And finally, multi-value properties can be tricky to set properly via properties. We advise using the UI to set them.

All that said, it’s not clear to me why Cognitive Complexity should ignore these conditionals. What happens inside your error checking blocks? Is this analogous to the catch block of a try/catch in Java? (Note that catch blocks do increment Cognitive Complexity).

 
Ann

A post was split to a new topic: NOSONAR for Cognitive Complexity

A post was split to a new topic: Cognitive Complexity in Go