-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cxx:FileHeader not validated when using regular expression #2118
Comments
Hi @lg2de, the check is using the Java regex format.
See also https://www.baeldung.com/java-regexp-escape-char, you have to escape the metacharacters Regards, |
Thanks @guwirth for your comments.
But the issue is still not solved. The header is not accepted. |
Hi @lg2de, I wrote an unit test with your sample. In the test everything is working (#2121). Now could still be due to the following:
Regards, |
I opened this issue because I already tried before "everything" to find the root cause for myself. But I failed e.g. because I'm not able to compile the plugin locally. |
@lg2de that is really strange. Next step I could do is to setup an integration test. That would be an "end-to-end" test. Could you provide a source code file (file with header and at least one line of code). Upload it "somewhere" and provide a link here. Only wanna be sure I'm using same encoding, line endings, ...
Did you try setting |
All files I checked are either UTF8 with BOM or UTF8 without BOM or simple ASCII. It is not that easy to provide sample code files. I cannot share internal code because it is protected. BTW, it would be great to have "all" combination of encoding and line ending in the integration test(s).
|
- improve check, regex start searching from the beginning of a line now (add `^` to the regex) - better sample
- improve check, regex start searching from the beginning of a line now (add `^` to the regex) - better sample
- improve check, regex start searching from the beginning of a line now (add `^` to the regex) - better sample
- improve check, regex start searching from the beginning of a line now (add `^` to the regex) - better sample
- BOM support - support UTF8, UTF16, ... - improve check, regex start searching from the beginning of a line now (add `^` to the regex) - better unit test samples - add integration tests
- BOM support - support UTF8, UTF16, ... - improve check, regex start searching from the beginning of a line now (add `^` to the regex) - better unit test samples - add integration tests
Thanks for taking care!! |
Hi @lg2de, please read https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Upgrade-the-Plugin, there are some changes with 2.0. Please turn debug info on during scanning, there should be according hints. Regards, |
Hi @lg2de, we also added an integration test with files with/without BOM and different line endings. They are working we can’t reproduce the problem.
Please try to isolate the problem on your system:
Regards |
@lg2de I still have no idea what the issue here could be. We did a fix for header files maybe that helps (#2142)? |
With the latest version sonar-cxx-plugin-2.0.1.2662.jar the header check seems to be ok now. |
Describe the bug
We have configured a regular expression for the rule
cxx:FileHeader
:Recently we have changed the name of the company. So, for some time we have two different valid headers. The current should look like this:
I guess the expression is correct because the same expression is working fine for C# files (csharpsquid:S1451).
Anyway the CPP files shows the issue:

To Reproduce
Unfortunately I do not know how to reproduce.
Maybe it is related to the multiline expression?
Expected behavior
The header should be accepted in old and new format.
Desktop:
Please help to identify the root cause. What information do you need?
The text was updated successfully, but these errors were encountered: