Copyright header regex not working

Hi, we have a problem on a specific rule and our research on the web were not successful.

Sonarqube Version : 7.9.1 (build 27448)
We have a problem meeting the requirements of rule c:S1451
Track lack of copyright and license headers

The rule definition of the language + quality profile we are using:

The proofs that it works in some online tester:

in VsCode:

and that’s where we are at after analysis:
after-analysis

So right now we are blocked and out of ideas to solve this problem, does someone knows how to manage that? or where is my error?

Thanks in advance for the help!

Hi @doudouClem,

as written in the rule description the regex should be in POSIX format, you should change you regex to:

^\/\*[[:space:]]*(Copyright|copyright|COPYRIGHT)[[:space:]]*[0-9]{4}[[:space:]]*\*\/

note that [\s\S] becomes [[:space:]].

aah ! ok, it looks like it’s working, but is it normal that it’s so slow ? I mean we can see some performance impact on 600 LoC files, and 1000 LoC gets almost 10 seconds to be analyzed when it was only less than a second before.
Am I missing something here ? or do we really have to rework this regex ?
Could changing the java memory allocated to the sonarscanner change this you think ?

Hi @doudouClem,

I reviewed the implementation and indeed it may affect the use case regex and big files. I created a ticket to improve that: CPP-2513. Thank you for the feedback or we would have not spotted it.

1 Like

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