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

Custom rules limited to 4000 chars #1548

Closed
gerboengels opened this issue Aug 28, 2018 · 10 comments · Fixed by #1566 or #1781
Closed

Custom rules limited to 4000 chars #1548

gerboengels opened this issue Aug 28, 2018 · 10 comments · Fixed by #1566 or #1781
Assignees
Labels
Milestone

Comments

@gerboengels
Copy link

Since SonarQube 7.0, there is a limit on the length of configuration settings. In our case, we use some XML in "Administration > C++ (Community) > Clang-Tidy custom rules" which exceeds the (new) limit of 4000 characters. Before SonarQube 7.0 this limit did not exist.

I think the regression was introduced in this SonarQube commit, for feature 10040.

I don't know whether the cxx plugin can work around the issue, or if it should be fixed in SonarQube?

cxx plugin version: 1.0.0
Current SonarQube version: 7.2.0.13530

@guwirth
Copy link
Collaborator

guwirth commented Aug 28, 2018

Hi @gerboengels,

"Administration > C++ (Community) > Clang-Tidy custom rules" which exceeds the (new) limit of 4000 characters.

thanks for this hint. Think we can't workaround this because seems to be an SQ core issue. Like to ask you to create an issue in the SQ community: https://community.sonarsource.com/

Regards,

@jmecosta
Copy link
Member

jmecosta commented Aug 28, 2018 via email

@yachoor
Copy link
Contributor

yachoor commented Sep 3, 2018

@jmecosta Did you try editing Clang-Tidy custom rules through SonarQube UI in latest release?
It seems the limit only exists in UI validation (Validation failed. 'value' length (15617) is longer than the maximum authorized (4000)).
As a workaround I edit it directly in database

@gerboengels
Copy link
Author

@jmecosta I found this after upgrading SQ from 6.x to 7.2, and then trying to modify the mentioned field. When clicking on save, the UI says it cannot be saved. But no crashes or anything.

@gerboengels
Copy link
Author

@yachoor Will try editing the database directly

@jmecosta
Copy link
Member

jmecosta commented Sep 4, 2018

@yachoor ok, we dont have probelms since we are only using the custom rules place holder and those do not face this issue. and to be honest that one will stop working at some point since its the same type of variable however its a multivalue property and for some reason there is not check on that in the ui. Supose db has not limitations.

https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/CxxPlugin.java#L301

that said:

@guwirth, @Bertk due to this newly introduced limitation. we can have 2 ooptions,

1, drop this support. and let users create the rules using rest api. I do this all the time.
2. convert all those into multi values and then users can split those into files of 4k characters or less.

what would be the best solution?

@jmecosta jmecosta added bug and removed question labels Sep 4, 2018
@guwirth
Copy link
Collaborator

guwirth commented Sep 6, 2018

1, drop this support. and let users create the rules using rest api. I do this all the time.

@jmecosta independent which way we are going: could you describe how it works with the REST API? Which commands are you using?

  1. convert all those into multi values and then users can split those into files of 4k characters or less.

Don't know if this is a good idea. Have the feeling the configuration interface is already too big.

@jmecosta
Copy link
Member

jmecosta commented Sep 6, 2018

would be something like this:
for each repo we create a template rule: https://github.com/jmecsoftware/sonarqube-roslyn-plugin/blob/master/sonar-roslyn-plugin/src/main/java/org/sonar/plugins/roslyn/RulesDefinitionCSharpRoslyn.java

the user can straight away create new rules based on this template rule. since this would be really a big work then you can use the "/api/rules/create" to post a new rule. how users use the rest end point its up to them, im using a f# library see
https://github.com/TrimbleSolutionsCorporation/VSSonarQubeExtension/blob/master/SonarRestService/SonarRestService.fs#L741

this would solve the current problem. however its a bit more work for end users.

@yachoor
Copy link
Contributor

yachoor commented Sep 24, 2018

Last time I checked it did not allow to create rules with keys containing '-'. Before there was clang-tidy support I used to pass it's output as gcc with template rules, but I had to replace every '-' with '_' when creating rule from template and than fix it manually in database.

@guwirth
Copy link
Collaborator

guwirth commented Sep 26, 2018

SQ will add an API to relating external rule info https://jira.sonarsource.com/browse/MMF-1332. Maybe that is an solution?

ivangalkin added a commit to ivangalkin/sonar-cxx that referenced this issue Oct 1, 2018
step 1 in order to address SonarOpenCommunity#1560 (and SonarOpenCommunity#1548)

* TableGen -dump-json over the Diagnostic.td and parse te resulting json
* The result is identical to http://clang.llvm.org/docs/DiagnosticsReference.html
ivangalkin added a commit to ivangalkin/sonar-cxx that referenced this issue Oct 5, 2018
addresses SonarOpenCommunity#1560
fixes SonarOpenCommunity#1548

* gnerate JSON file from Diagnositc.td
  `llvm-tblgen -dump-json <src_dir>/tools/clang/include/clang/Basic/Diagnostic.td > output.json`
* parse JSON in order to generate rules ( incl. types, severities and descriptions)
* the result is identical to http://clang.llvm.org/docs/DiagnosticsReference.html

TODO
* check if prefix 'clang-diagnostics-' applies to all diagnositcs
* check if rule-IDs in clang-tidy report match the rule-IDs in the clangtidy.xml
ivangalkin added a commit to ivangalkin/sonar-cxx that referenced this issue Oct 5, 2018
addresses SonarOpenCommunity#1560
fixes SonarOpenCommunity#1548

* gnerate JSON file from Diagnositc.td
  `llvm-tblgen -dump-json <src_dir>/tools/clang/include/clang/Basic/Diagnostic.td > output.json`
* parse JSON in order to generate rules ( incl. types, severities and descriptions)
* the result is identical to http://clang.llvm.org/docs/DiagnosticsReference.html

TODO
* check if prefix 'clang-diagnostics-' applies to all diagnositcs
* check if rule-IDs in clang-tidy report match the rule-IDs in the clangtidy.xml
ivangalkin added a commit to ivangalkin/sonar-cxx that referenced this issue Oct 5, 2018
addresses SonarOpenCommunity#1560
fixes SonarOpenCommunity#1548

* gnerate JSON file from Diagnositc.td
  `llvm-tblgen -dump-json <src_dir>/tools/clang/include/clang/Basic/Diagnostic.td > output.json`
* parse JSON in order to generate rules ( incl. types, severities and descriptions)
* the result is identical to http://clang.llvm.org/docs/DiagnosticsReference.html

TODO
* check if prefix 'clang-diagnostics-' applies to all diagnositcs
* check if rule-IDs in clang-tidy report match the rule-IDs in the clangtidy.xml
@guwirth guwirth reopened this Oct 17, 2018
@guwirth guwirth added this to the 1.2.1 milestone Nov 14, 2018
@guwirth guwirth modified the milestones: 1.2.1, 1.2.2 Dec 23, 2018
@guwirth guwirth removed this from the 1.2.2 milestone Feb 9, 2019
@guwirth guwirth self-assigned this Jan 5, 2020
@guwirth guwirth added this to the 1.3.2 milestone Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 participants