-
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
4.5.2 API #435
4.5.2 API #435
Conversation
We discuss this before, the issue here is that we are not using a recommended way of defining rules. The XML that we put in the web ui is no more supported. We have two alternatives we get the XML parser file from earlier versions and keep it in the cxx plugin so we can still use the same way of defining rules or we drop it and use only the recommended way using template rules. Those are already available so we would only need to remove the properties and the extension that parses the XML for each sensor. I promise to provide a tool to use the XML we have and create template rules accordingly. |
I'm still thinking that the possibility to add rules from other tools with a simple XML rule file is one of the biggest advantages of the cxx plugin. missing symbols using 4.5.2:
Found this link:
|
heres an example of that in use ive took a look at it. and would need to convert the xml from the ui to this... not sure whats best |
plus not sure how this works with the current rules that are defined in the resources xml |
Are there opinions from others? |
There is also the class RulesDefinitionXmlLoader: http://javadocs.sonarsource.org/4.4/apidocs/org/sonar/api/server/rule/RulesDefinitionXmlLoader.html |
seems the format is different than what we use. but guess this would be a way of doing it |
Still like to here other opinions. |
dont think you can have them in file anymore, that option has been deprecated in favor of having those in web ui. at least it was the reason why we decided to put them in web ui in first place. there are 2 big advantages of defining those in using custom rules: third thing is sensors i am using provided by sonar guys use custom rules has the way extending rules. so if doing the same most of the documentation is already provided by platform. |
Input for RulesDefinitionXmlLoader is a stream. So could also be a file again? |
But the case to use this is to include the file in the jar only, where in On Tue, Mar 3, 2015, 08:14 Günter Wirth [email protected] wrote:
|
You are right. This argument convinced me. |
But still the question is use template rules or crate helper class to read On Tue, Mar 3, 2015, 09:12 Günter Wirth [email protected] wrote:
|
Hi guys,
http://javadocs.sonarsource.org/4.4/apidocs/org/sonar/api/server/rule/RulesDefinitionXmlLoader.html looks like there is just a change in the format, conceptually its the same. I.e. you have some XML files, probably packaged with your plugin, and there is an API (a class) which can be used to read them in. @jmecosta not sure what you mean by using the REST api etc. When is the rule creation supposed to run? Still at the plugin load time, no? |
Not for custom rules, that was the main thing we were discussing. These So we could use the rest api to create the custom rules instead of having a For rules that come bundled I agree on what you propose On Wed, Mar 4, 2015, 00:58 Waleri Enns [email protected] wrote:
|
Sounds like both makes sense. Seems they do not exclude each other:
|
Looking to the source code of RulesDefinitionXmlLoader the reader is backward compatible. Means supporting also our current XML format for rules. |
FYI. Working on this. Will provide solution next days. |
Add a first preview. Unit tests still failing... |
fix some unit tests, nearly functional now. still open:
|
Ok I take a look, likely some common rules have been dropped On Thu, Apr 2, 2015, 18:45 Günter Wirth [email protected] wrote:
|
@jmecosta I think I'm one step closer to the goal. Getting now 'name of rule is empty'? |
seems tests have been updated in the java plugin: see |
Think I got it. Tags of checks are different now. |
Hi, can you please give me some details on the compile Errors. I cannot reproduce it ( I see only some failing tests …
|
Hello @Bertk. After many other changes the problem has gone. Only remaining problem seems to be CxxCommonRulesEngineTest. Problem below was usage of obsolete @rule in all checks. I also changed this, see last upload. Currently I'm getting NoClassDefFound and I have no glue why?
|
I got that one also after using the java plugin code, and did not find any On Sat, Apr 4, 2015, 10:05 Günter Wirth [email protected] wrote:
|
@jmecosta , @Bertk , @Typz, @wenns
My feeling is
Maybe someone of you can give me a hint? |
I am not sure but did you this https://jira.codehaus.org/browse/SONAR-6162. SQ Java plug-in has a section to set the internal key:
|
Loading the rules seems to work. My feeling is that there is something wrong with CommonRulesEngine. Setting a breakpoint to doEnableRules it is not called. The method provide is crashing?
|
Ok first time green now.
|
What are the sqale parameters missing? The ones in the checks module should already have definition in the model |
See an example here https://github.com/guwirth/sonar-cxx/blob/enhancement/357_45_API/cxx-checks/src/main/java/org/sonar/cxx/checks/CommentedCodeCheck.java @rule( To try things they are all READABILITY / 1min at the moment. Idea was to copy settings from Phyton checks. They have similar checks.
Where are they defined?
|
There should be ids already there. You can have those or in the model or On Sat, Apr 4, 2015, 17:14 Günter Wirth [email protected] wrote:
|
Having them directly in the Java files as annotations seems to be the best choice?
|
I personally like all of them to be in one place. But either way I dont see On Sat, Apr 4, 2015, 17:23 Günter Wirth [email protected] wrote:
|
- mark deprecated API usage - replace RuleRepository with RulesDefinition (http://grepcode.com/file/repo1.maven.org/maven2/org.codehaus.sonar/sonar-plugin-api/4.5.2/org/sonar/api/server/rule/RulesDefinition.java#RulesDefinition) - replace XMLRuleParser with RulesDefinitionXmlLoader (http://javadocs.sonarsource.org/4.4/apidocs/org/sonar/api/server/rule/RulesDefinitionXmlLoader.html) - update unit tests according to: - https://github.com/SonarSource/sonarqube/blob/branch-4.3/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java - https://github.com/SonarSource/sonarqube/blob/branch-4.3/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java - convert checks to new format - set Sqale values in Java files - Migrate text colorizing to use Highlightable interface: https://jira.codehaus.org/browse/SONARJS-379 - using JavaScript as base: https://github.com/SonarCommunity/sonar-javascript/tree/master/sonar-javascript-plugin/src/main/java/org/sonar/plugins/javascript/highlighter Hints: - needs SQ 4.5.2 or later for testing - needs Java 1.6 or later
Migrate text colorizing to use Highlightable interface: https://jira.codehaus.org/browse/SONARJS-379 |
- set C++ comment style in highlighter
Current problems below.