'Ignore Issues in Blocks' Regex Help

Hi all!

I’m on Sonarqube version 7.9.4.35981

I’m currently running into an issue where some new code is being called duplication, but it is not relevant because it is just some import lines:

What I would like to do is exclude all the import blocks from being considered in duplication counts. I currently have the following set up on the interface to try and exclude these blocks, but both options do not seem to work.

Any help is appreciated,
Thanks.

Hi,

I think (know!) you’re thinking this mechanism is more sophisticated than it is. You need to provide a positive match pattern. Something like //end imports (which of course implies editing your files which is an obvious PITA and probable no-go). Also, I’m pretty sure that this is a line-by-line detection, so an end pattern of \n\n isn’t going to work.

 
:woman_shrugging:
Ann

Thanks for your response!

So in screenshot I tried the more simple solution of just looking for “imports” as the start string and "; as the end string. I’m guessing that "; won’t work as the end option because it’s not a simple string?

Hi,

No, it should work… if you have a line that consists entirely of ;. As I said,

Also of note, what this exclusion type is looking for is the pattern that marks the beginning of a block of lines, e.g.

// Generated

And the pattern that marks the end of the block, e.g.

// End generated

 
HTH,
Ann

OH. I see. Wow that does not do what I thought it did.

Alrighty, I’m on the same page now. Thank you for your help :slightly_smiling_face:. I’ll just exclude the file until the next new code period. I don’t want to add any lines without a good reason.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.