Skip to content
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

allow underscore character in clang-tidy rules #1951

Closed
guwirth opened this issue Oct 6, 2020 · 6 comments · Fixed by #1952
Closed

allow underscore character in clang-tidy rules #1951

guwirth opened this issue Oct 6, 2020 · 6 comments · Fixed by #1952
Assignees
Milestone

Comments

@guwirth
Copy link
Collaborator

guwirth commented Oct 6, 2020

from @elviiix, #1949

Can you allow underscore character in clang-tidy rules, it's allowed there by clang-tidy itself and warnings not importing in SonarQube was rather unexpected.

--- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidySensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidySensor.java
@@ -101,7 +101,7 @@ public class CxxClangTidySensor extends CxxIssuesReportSensor {
                 ruleId = txt.substring(i + 1, txt.length() - 1);
                 break;
               }
-              if (!(Character.isLetterOrDigit(c) || c == '-' || c == '.')) {
+              if (!(Character.isLetterOrDigit(c) || c == '-' || c == '.' || c == '_')) {
                 break;
               }
             }
-- 

@guwirth
Copy link
Collaborator Author

guwirth commented Oct 6, 2020

@elviiix

@elviiix
Copy link

elviiix commented Oct 6, 2020

For custom rule.
I had a rule mentioning size_t. It was successfully imported and activated in SonarQube, and then during log processing warning with this rule was left out and not imported in SonarQube project.
Underscore is quite common character in identifiers (and probably it would be good to at least inform somehow that warning was left out due to naming problems even with other characters).

@guwirth guwirth self-assigned this Oct 7, 2020
@guwirth guwirth added this to the 2.0.0 milestone Oct 7, 2020
@guwirth
Copy link
Collaborator Author

guwirth commented Oct 7, 2020

@elviiix means rule is: file:line:column: warning: text [size_t]?

and probably it would be good to at least inform somehow that warning was left out due to naming problems even with other characters

To detect a warning parser is looking for [...] at the end. [ or ] could be also part of the text before the rule id. How would you like to detect "ignored line"?

@elviiix
Copy link

elviiix commented Oct 8, 2020

To detect a warning parser is looking for [...] at the end. [ or ] could be also part of the text before the rule id. How would you like to detect "ignored line"?
Can't say for sure, but I think if you break out due to invalid character in rule name:

-              if (!(Character.isLetterOrDigit(c) || c == '-' || c == '.')) {
+              if (!(Character.isLetterOrDigit(c) || c == '-' || c == '.' || c == '_')) {
-->               break;
               }

it makes sense to issue warning at least.

@guwirth
Copy link
Collaborator Author

guwirth commented Oct 8, 2020

@elviiix I have a solution but without warning => #1952

Warning:

  • still don't know how many errors/warnings exist without rule id. For all of them you would get a warning?
    sample: This is a warning.
  • could be also a ] at the end which is part of the text (without rule id)
    sample: Don't use ]

In which cases should there be a warning?
What is the warning: error/warning without rule id?

@elviiix
Copy link

elviiix commented Oct 8, 2020

Not 100% sure, but looks ok for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants