findbug、p3c、checkstyle、sonar安裝使用


 idea插件安裝方式:

Preferences—>Plugins—>查找插件—>Install

Preferences—>Plugins—>Install plug from disk —>選擇下載好的插件—>安裝

p3c:

官方安裝使用手冊:

https://github.com/alibaba/p3c/blob/master/idea-plugin/README_cn.md

便捷使用:

實時檢測+手動選擇編碼規約掃描(使用快捷鍵ctrl+shift+alt+j或者鼠標右鍵彈出菜單)

錯誤提示(ctrl+f1)

快速修改(alt+enter)

缺陷級別:

1.Blocker, 2.Critical, 3.Major;

FindBugs-IDEA:

離線安裝包下載地址:

https://plugins.jetbrains.com/plugin/download?rel=true&updateId=29582

安裝使用參考文檔:

http://blog.csdn.net/qq_27093465/article/details/64923239

便捷使用:

選擇文件或項目后鼠標右鍵選擇FindBugs

缺陷級別:

1.Bad pratice編程的壞習慣

2.Malicious code vulnerability 惡意代碼漏洞

3.Dodgy code 糟糕的代碼

4.performance 性能

5.correctness 代碼的正確性 這一項應該算是最重要的

checkstyle:

安裝使用參考文檔:

https://www.jianshu.com/p/25d2a197a59a

便捷使用:

文件內右鍵選擇check current file

sonar:

安裝使用可參考文檔:

https://my.oschina.net/zzuqiang/blog/843406

http://blog.csdn.net/hunterno4/article/details/11687269

http://developer.51cto.com/art/201311/418198.htm

https://www.linuxidc.com/Linux/2016-08/133877p2.htm

 

sonar使用實例:

1.sonar安裝配置和啟動

解壓縮sonar安裝包

修改sonar配置:

cd sonar/conf

vi sonar.properties

sonar.jdbc.username=**

sonar.jdbc.password=**

sonar.jdbc.url=jdbc:mysql://**:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

sonar.sorceEncoding=UTF-8

sonar.jdbc.driverClassName=com.mysql.jdbc.Driver

運行:

/usr/local/sonarqube/bin/linux-x86-64/sonar.sh start

 

2.maven配置和啟動sonar分析

項目配置:

maven->setting.xml修改配置(不需要添加數據庫信息):

<profile>

   <id>sonar</id>

   <activation>

       <activeByDefault>true</activeByDefault>

   </activation>

   <properties>

      <sonar.host.url>http://**:9000</sonar.host.url>

   </properties>

</profile>

運行:

mvn clean install

mvn sonar:sonar

 

問題1及解決:

問題:

Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.

Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.

Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.

https://stackoverflow.com/questions/35230453/sonar-jdbc-properties-are-not-supported-anymore-in-sonarqube-5-3-version

不用配置數據庫信息,只需要配置url,數據會直接渲染在網頁上。

 

問題2及解決:

問題:

使用sonar的時候報錯svn: E175002: Connection has been shutdown: javax.net.ssl.SSLProtocolException: handshake alert:  unrecognized_name

解決:

https://support.xebialabs.com/hc/en-us/community/posts/203291975-SOLVED-javax-net-ssl-SSLProtocolException-handshake-alert-unrecognized-name

運行時加參數:

mvn sonar:sonar -Djsse.enableSNIExtension=false

(Sometimes, when Java 1.7 communicates via HTTPS with webservers, that configured with multiple hostnames, it can throw the following error: javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name.

In this case, the solution can be either to fix the configuration of web server, or set jsse.enableSNIExtension into false by adding

to following line to the start options of the server.

-Djsse.enableSNIExtension=false)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM