Installing Sonar Eclipse is pretty simple. For instructions, prerequisites and a demonstration video go to Installing Sonar Eclipse.
Configure Sonar Eclipse
Sonar Eclipse is pre-configured to access local Sonar server listening on http://localhost:9000/. To use an other address, you need first to define this server by using the Eclipse global Preferences window :
Link projects to Sonar server
Once Sonar server is defined, the next step is to "link" eclipse projects with projects defined and analysed in Sonar server(s). This linkage operation can be done by right-clicking on the the project into the "Package explorer", and then by choosing "Configure -> Associate with Sonar..." :
You are now all done with configuration and can start using Sonar Eclipse.
Unlink a project from Sonar server
This operation can be done by right-clicking on the the project into the "Package explorer", and then by choosing "Configure -> Remove Sonar Nature" :
Use Sonar Eclipse
Sonar Eclipse provides one eclipse perspective and four eclipse views. Those eclipse views can of course be used outside the "Sonar" eclipse perspective, but this tutorial describes the default "Sonar" eclipse perspective layout.
To activate the "Sonar" eclipse perspective, click on "Windows -> Open Perspective -> Other ..." and select "Sonar" :
Measures view
The Measures view allows to gather all available measures on the selected ressource. Most of the time, developers focus their attention on only a few metrics like complexity, uncovered lines of code by unit tests, duplicated lines, ... and want to get a quick overview on those metrics. That's why favourite metrics are displayed on the top of the Measures view. Adding or Removing a metric from the favourites list is possible by right clicking on the metric name :
Violations view
The Violations view displays the list of violations to quality rules for the selected ressource :
A double-click on a violation opens the source code editor and highlights the violation :
Once a violation has been fixed, you can simply delete it by clicking on the violation icon and then by selecting the "Delete violation" item. Deleting a violation also removes it from the Violations view :
Hotspots view
The Hotspots view allows to quickly identify hotspots on files according to favourite metrics (defined in the Measures view). You can for instance look at files with the greatest number of duplicated lines, greatest number of violations, greatest number of uncovered lines by unit tests...
Web view
The Web view displays the web Sonar dashboard (for projects and packages) or the web Sonar ressource viewer (for files). This web page can be used to access information and services (cloud, treemap, ...) that are not yet natively available in Sonar Eclipse :
Local analysis
By default Sonar Eclipse takes care to automatically collect information from the Sonar Web server and decorates the source code on-the-fly. This default behavior is pretty useful as it doesn't consume any CPU or memory on the developer's computer while quickly displaying valuable quality information as soon as a new source file is opened. But if lot of source code is modified locally, quality information available remotely might be desynchronized after a while. In that case, a local quality analysis can be run before committing any chances to the source code repository and with the same quality profile used to analyse the project remotely.
Switching from the remote to the local mode can be done by right-clicking on the the project into the "Package explorer", and then by choosing "Configure -> Sonar -> Analyse -> Locally". As soon as this mode is selected a local analysis is launched to update Violations and Measures views.
Later, at any time, you can run a new local analysis by choosing "Configure -> Sonar -> Run Local Analysis.
|
Be Careful Even in local mode, the Hotspots and Web views still display remote data. |
Reviews
|
Feature available since Sonar Eclipse 2.1 |
A Sonar Mylyn connector allows to track all open reviews assigned to the current user. To start using this feature, a new Sonar task repository and a query to get all reviews assigned to the current user must be first created (see the Mylyn documentation page) :
Then the "Task List" view must be used to start working on all those assigned reviews :
From there, double clicking on a review open the detail of that review :
All operations on reviews available through the Sonar web interface are also available in Mylyn, so a review can be commented, fixed, reassigned, flagged as false-positive and reopened. Moreover a review can be created directly from the Eclipse source code editor on an existing violation :
This Mylyn extension has currently the following limitations that should be quickly fixed
- There is no way to create a review that doesn't relate to an existing violation
- There is no way to create a Mylyn query with filters in order for instance to retrieve reviews only on a project, or reviews assigned to another user
相关推荐
代码覆盖率工具包集合,包含jacoco,sonar,sonar-scanner等。用于代码的规范检查、覆盖率检查等。
sonar eclipse插件sonarlint,原先的插件已经被启用,这是最新的,如果连接本地sonar服务器,需要在eclipse.ini中配置启动参数,参数为org.sonarlint.eclipse.core/server_url 值为sonar服务器地址,如果不配置默认...
sonar-eclipse-plugin
SonarLint 代码检查工具,IDEA 插件。
Sonar 用于代码质量管理的开放平台。通过插件机制,Sonar 可以集成不同的测试工具,代码分析工具,以及持续集成工具
sonar-eclipse插件使用说明,怎么在eclipse中查看违规的情况。
sonarlint-eclipse, Eclipse的SonarLint SonarLint Eclipse 插件建筑 mvn clean verify Eclipse 中的开发安装 m2eclipse,然后Tycho扩展到 m2eclipse:窗口-> 首选项->
java代码规范检查eclipse插件,对代码质量的规范性进行检查
sonarLint 插件 供离线安装 ,用于检查代码 ,sonarLint 插件 ,用于检查代码 ,sonarLint 插件 ,用于检查代码 ,sonarLint 插件 ,用于检查代码
Sonar 是一个用于代码质量管理的开源平台,用于管理源代码的质量,通 过 Eclipse 插件形式,可以支持包括 java, C#, C/C++, PL/SQL, Cobol, JS, Groovy 等等二十几种编程语言的代码质量管理与检测。
单元测试代码覆盖率浅谈,供大家参考学习
sonarlint for eclipse2版本
Sonar开源的Java源代码管理平台UT覆盖率.pdf
sonar 是一个代码静态坚持工具网站,可以集成PMD,findbugs等静态坚持工具。
Sonar,Sonar+maven,Sonar+eclipse
通过sonar扫描java代码,可以帮忙进行代码优化,一般在项目最后上线前都要求进行代码扫描,选用此扫描工具是一个不错的选择,压缩包里包含了sonarqube-5.6.7.zip,sonar-scanner-2.8.zip,Sonar代码扫描环境搭建.docx...
sonar4版本扫描辅助程序. 向服务器上传代码并做扫描分析. 使用方式: CMD切换到项目根目录下(sonar-project.properties文件所在目录)运行 sonar-runner
检查代码规范插件,解压,将sonar-plugin文件夹下的两个文件夹复制到eclipse安装目录下,重启eclipse,在项目目录上右键便可看到SonarLint字眼,即右键-SonarLint-AnaLyze
sonar 是一个代码静态坚持工具网站,可以集成PMD,findbugs等静态坚持工具。
最新版本SonarLint-3.4.2.2586版本。IntelliJ 3.4.1和3.4.2版本也能用。