Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Sonar
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="icon=false|title=Table of Contents" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86aWNvbj1mYWxzZXx0aXRsZT1UYWJsZSBvZiBDb250ZW50c30&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p><img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e3RvY30&locale=en_GB&version=2" data-macro-name="toc"></p></td></tr></table><p>To understand how rules extension works in Sonar, please refer to the <a class="confluence-link" href="/display/SONAR/Extending+Coding+Rules" data-linked-resource-id="183205932" data-linked-resource-type="page" data-linked-resource-default-alias="Extending Coding Rules" data-base-url="http://docs.codehaus.org">Extending Coding Rules</a> documentation.</p><h1>Extending PHP_Codesniffer Rules</h1><p>PHP_CodeSniffer is built on an extensible architecture where you can define you own rules.</p><p>To do so, you just have to create your own rules.xml file following the below format:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><?xml version="1.0" encoding="ISO-8859-1"?> <rules> <rule key="PEAR.Commenting.FileComment.TagIndent" priority="MAJOR"> <category name="Maintainability" /> <name>Tag comment incorrectly indented</name> <configKey>TAG_INDENT</configKey> <description>@category tag comment incorrectly indented</description> </rule> </rules> </pre></td></tr></table><p>This file must be copied in the directory $SONAR_HOME/extensions/rules/<strong>php_codesniffer_rules</strong>/. You have to restart your Sonar server to make it available for PHP profiles.</p><p>The value of the "key" attribute is a combination of different elements: <strong><code><standard_folder>.<sniff_subfolder>.<sniff_file_without_Sniff_suffix>.<error_name></code></strong>. <br />For instance, for the given key above ("<code>PEAR.Commenting.FileComment.TagIndent</code>"):</p><ul><li>"<code>PEAR</code>" is the folder found in the "Standards" directory of PHPCodeSniffer install directory</li><li>"<code>Commenting</code>" is the folder found in the "Sniffs" directory of the "PEAR" folder</li><li>"<code>FileComment</code>" is the name of the PHP file "FileCommentSniff.php" for which "Sniff.php" was removed</li><li>"<code>TagIndent</code>" is the name of the error that can be found in "FileCommentSniff.php" file</li></ul><h1>Extending PHPMD Rules</h1><p>Extending PHPMD works the same way as PHP_CodeSniffer, except that you have to copy your file containing your custom violations in $SONAR_HOME/extensions/rules/<strong>phppmd_rules</strong>/</p><p>This XML file must look like the following example:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><?xml version="1.0" encoding="ISO-8859-1"?> <rules> <rule key="Code Size Rules/CyclomaticComplexity" priority="CRITICAL"> <name><![CDATA[Class cyclomatic complexity exceed maximum]]></name> <configKey>rulesets/codesize.xml/CyclomaticComplexity</configKey> <category name="Maintainability"/> <description><![CDATA[Class cyclomatic complexity exceed maximum]]></description> <param key="maximum" type="i"> <description><![CDATA[The maximum cyclomatic complexity threshold. Default is 10.]]></description> </param> </rule> <!-- other rules ... --> </rules> </pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced