Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current ·  View Page History
Important

Once rules have been added to extensions/rules, they should be enabled in the relevant quality profile in Sonar. Only after this has been done, the analysis can be performed

Extend Coding Rules - Via extensions/rules

From version 0.2, its possibleto extend the rules available in quality profiles for any tool. To do this a directory with tool name and a xml with the description of the rules should be provided. For example

  • [Sonar Server Install Dir]\extensions\rules\cppcheck for cpp check sensor

Rules XML Format 

Xml Description

Example

<rules>
<rule key="RULE_ID">
<name><![CDATA[ ... put here the human readable name of this rule ... ]]></name>
<configKey><![CDATA[RULE_ID@$(EXTERNALSENSORCLASS)]]></configKey>
<category name=" ... category type ... " />
<description><![CDATA[ ... put here the human readable description of this rule ... ]]></description>
</rule>
</rules>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rules>
<rule key="Te0001DataContextCannotBeSet">
<name><![CDATA[Te0001DataContextCannotBeSet]]></name>
<configKey>
<![CDATA[Te0001DataContextCannotBeSet@PC_LINT]]>
</configKey>
<category name="Maintainability" />
<description>
<![CDATA[ Data Context Should no be set, please use another approach ]]>
</description>
</rule>
</rules>

AttributesDescription
key [RULE_ID]Id of the rule, should match the id in the external reports
nameCan be really anything, in the quality profile in sonar its the first name that is displayed per rule
configKeyThis key is used later by the sensor to configure the code analyzer (Extending+Coding+Rules )
category nameCan be anything, examples include Maintainability Style Usability etc
descriptionIn the quality profile in sonar ui, the description will be show after expanding each rule
Labels
  • None