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
<h2>Best practices</h2><ul><li>Build with maven before committing into SCM (Git or Subversion)</li><li>Commit frequently</li><li>Do not commit incomplete changes (SCM is not a backup system)</li><li>Do not commit IDE files (.settings, .project, .classpath, .idea, *.iml, *.ipr, *.iws)</li><li>Use meaningful comments when doing a commit, always with the JIRA key and title (e.g. "SONAR-6 Apply license LGPL") - see <a href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html">Note About Git Commit Messages</a></li><li><a href="http://xircles.codehaus.org/projects/sonar/lists">Subscribe</a> to the mailing list dev@sonar.codehaus.org</li><li>Overuse JUnit tests with the help of <a href="http://docs.codehaus.org/display/FEST/Fluent+Assertions+Module">FEST Assert</a> and <a href="http://code.google.com/p/mockito/">Mockito</a></li><li>Think IoC (Inversion of Control pattern)</li><li>Don't reinvent the wheel : use standard libraries like <a href="http://commons.apache.org/lang/">commons-lang</a>, <a href="http://commons.apache.org/io/">commons-io</a> and <a href="http://code.google.com/p/guava-libraries/">guava</a> (formerly known as google-collections). Commons-collections is deprecated since Sonar 1.10.</li><li>Use comments and javadocs only when necessary</li><li>API Javadoc - use "@since <version>" and "@deprecated in <version>"</li><li>Do not forget the license header on all the Java and Ruby files</li><li>Respect the code formatting described below</li><li>Follow <a class="confluence-link" href="/display/SONAR/Error+Handling" data-linked-resource-id="228179043" data-linked-resource-type="page" data-linked-resource-default-alias="Error Handling" data-base-url="http://docs.codehaus.org">error handling guidelines</a></li><li>Eat your own food : have a look at <a href="http://nemo.sonarsource.org/project/index/org.codehaus.sonar:sonar">Sonar</a> and <a href="http://nemo.sonarsource.org/dashboard/index/org.codehaus.sonar-plugins:all">Sonar plugins</a> on Nemo.</li><li>Follow <a href="http://maven.apache.org/developers/conventions/code.html#POM_Code_Convention">Maven conventions</a></li></ul><h2>Source Encoding</h2><p>Source code encoding should be set to <strong>UTF-8</strong> to prevent cross-platform encoding issues.</p><p>UTF-8 is specified in parent POMs, so it is used by Maven when building the projects. However, it may not be set by default in your prefered IDE. The best practice is to force it for all your source code.</p><ul><li>For Eclipse : go to "Preferences -> General -> Workspace" and force the "Text file encoding" to "UTF-8"</li><li>For IntelliJ IDEA : go to "Settings -> File Encodings" and force the "IDE Encoding" to "UTF-8"</li></ul><h2>Code Style</h2><ul><li>Classes with acronyms are CamelCase : for example prefer PmdPlugin to PMDPlugin, or JavaNcssHandler to JavaNCSSHandler</li><li><p>Configure your IDE with the correct code style: see <a class="confluence-link" href="/display/SONAR/How+to+Build" data-linked-resource-id="46333977" data-linked-resource-type="page" data-linked-resource-default-alias="How to Build" data-base-url="http://docs.codehaus.org">the section "IDE Support"</a>. </p></li></ul><h2>Edit Ruby code</h2><p>The development mode is used to edit Ruby on Rails code. The application is automatically reloaded when Ruby files are saved. It avoids restarting the server. Changes are reloaded on the fly. Execute one of the following commands from the sonar-server/ directory to start the server :</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>sonar-server/derby-start.sh # for embedded database sonar-server/mysql-start.sh # for MySql sonar-server/postgresql-start.sh # for PostgreSQL </pre></td></tr></table><p>Then ruby code can be directly edited from sonar-server/src/main/webapp/WEB-INF/app.</p><h2>Debug Maven Analysis</h2><ul><li><p>Execute mvnDebug instead of mvn :</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>mvnDebug sonar:sonar </pre></td></tr></table></li><li>Attach your IDE to the remote process (the listening port is 8000).</li></ul><p>Example in Intellij Idea : Run -> Edit configurations -> Add new configuration -> Remote -> port 8000.</p><h2>Profile Maven analysis with JProfiler</h2><ul><li>Clone $MAVEN_HOME/bin/mvnDebug to mvnJProfiler and replace the MAVEN_DEBUG_OPTS property by :<br /> MAVEN_DEBUG_OPTS="-Xint -agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/Applications/jprofiler5/bin/agent.jar"</li><li>Start JProfiler -> Connect to an application on a remote computer</li></ul><h2>Tips and tricks</h2><h4>Log server-side SQL requests</h4><p>Here is how to log all the SQL requests executed from server :</p><ol><li>Download log4jdbc4-1.2.jar from <a href="http://log4jdbc.googlecode.com/files/log4jdbc4-1.2.jar">http://log4jdbc.googlecode.com/files/log4jdbc4-1.2.jar</a></li><li>Copy this jar here : $SONAR_HOME/war/sonar-server/WEB-INF/lib/log4jdbc4-1.2.jar</li><li><p><strong>IMPORTANT:</strong> Change the configuration of logback.xml because if not modified everything will be logged (<a href="http://code.google.com/p/log4jdbc/#5._Set_up_your_loggers">http://code.google.com/p/log4jdbc/#5._Set_up_your_loggers</a>)</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="language=html/xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6bGFuZ3VhZ2U9aHRtbC94bWx9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <logger name="jdbc.sqltiming"> <level value="OFF"/> <appender-ref ref="PROFILING_FILE"/> </logger> <logger name="jdbc.connection"> <level value="INFO"/> <appender-ref ref="PROFILING_FILE"/> </logger> <logger name="jdbc.audit"> <level value="OFF"/> <appender-ref ref="PROFILING_FILE"/> </logger> <logger name="jdbc.resultset"> <level value="OFF"/> <appender-ref ref="PROFILING_FILE"/> </logger> <logger name="jdbc.sqlonly"> <level value="OFF"/> <appender-ref ref="PROFILING_FILE"/> </logger></pre></td></tr></table></li><li><p>Restart sonar and you should be able to see :</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="language=none" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6bGFuZ3VhZ2U9bm9uZX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> 2012.07.02 16:04:06 INFO jdbc.sqltiming select params0_.rule_id as rule6_1_, params0_.id as id1_, params0_.id as id18_0_, params0_.default_value as default2_18_0_, params0_.description as descript3_18_0_, params0_.name as name18_0_, params0_.rule_id as rule6_18_0_, params0_.param_type as param5_18_0_ from rules_parameters params0_ where params0_.rule_id=679 {executed in 0 msec} </pre></td></tr></table><p><br /><br /></p></li></ol>
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