Want to Ignore code block from coverage as it cannot be covered with integration test

I have generated code coverage for golang source code and using sonarqube to do the analysis on it. I have used integration tests to hit source code. Problem is there is some blocks of source code which cannot be hit as part of integration tests as that code is edge case specific to production failures. Because of that code, my code coverage percentage is going down.
Is there a way to ignore that particular blocks of code, for example inside one file from line 122 to line 127, in other file from line 222 to line 234. I want to exclude this from coverage(not the whole file). It should show not covered in sonarqube UI.

I have already tried to use Narrowing the focus with an analysis scope


Block 1 settings



Block 2 settings



Hey there.

SonarQube relies entirely on the coverage report (with the exception of file-level code coverage exclusions) to tell it which lines can be covered. I suggest investigating what mechanisms your coverage tool has to suppress reporting coverage on specific lines.

Thanks Colin.