start
1 2 3 4 5 6 7 8 9
| docker run -d --name sonarqube \ -p 9797:9000 -p 9092:9092 \ -v /opt/sonarqube/temp:/opt/sonarqube/temp \ -v /opt/sonarqube/conf:/opt/sonarqube/conf \ -v /opt/sonarqube/extensions:/opt/sonarqube/extensions \ -e SONARQUBE_JDBC_USERNAME=username \ -e SONARQUBE_JDBC_PASSWORD=password \ -e SONARQUBE_JDBC_URL="jdbc:mysql://192.168.20.234:3306/sonar?useUnicode=true&characterEncoding=utf8" \ sonarqube:7.1
|
postgres db
1 2 3 4 5 6 7 8 9
| docker pull postgres:10 docker pull sonarqube:7.9.1-community docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=1 --name postgres postgres:10 docker run -d --name sonarqube \ -p 9000:9000 \ -e "SONARQUBE_JDBC_URL=jdbc:postgresql://192.168.114.131:5432/sonar" \ -e "SONARQUBE_JDBC_USERNAME=postgres" \ -e "SONARQUBE_JDBC_PASSWORD=1" \ sonarqube:7.9.1-community
|
plugins
1 2 3 4 5 6 7 8
| FROM sonarqube ADD ./sonar-l10n-zh-plugin-1.15.jar /opt/sonarqube/extensions/plugins/sonar-l10n-zh-plugin-1.15.jar ADD ./sonar-java-plugin-4.7.0.9212.jar /opt/sonarqube/extensions/plugins/sonar-java-plugin-4.7.0.9212.jar ADD ./sonar-findbugs-plugin-3.4.4.jar /opt/sonarqube/extensions/plugins/sonar-findbugs-plugin-3.4.4.jar ADD ./checkstyle-sonar-plugin-3.6.jar /opt/sonarqube/extensions/plugins/checkstyle-sonar-plugin-3.6.jar ADD ./backelite-sonar-swift-plugin-0.3.2.jar /opt/sonarqube/extensions/plugins/backelite-sonar-swift-plugin-0.3.2.jar ADD ./sonar-web-plugin-2.5.0.476.jar /opt/sonarqube/extensions/plugins/sonar-web-plugin-2.5.0.476.jar ADD ./sonar-javascript-plugin-2.21.0.4409.jar /opt/sonarqube/extensions/plugins/sonar-javascript-plugin-2.21.0.4409.jar
|
IDE Support
Eclipse
IDEA
maven项目sonar扫描本地配置和扫描相关命令
术语
- Reliability 可靠性
- Security 安全
- Maintainability 可维护性
- Coverage 覆盖率
- Duplications 重复
- Quality Gate 质量门限
- Compliant Solution 兼容的解决方案
sonar rules
建议手工关闭的规则:
- Field names should comply with a naming convention
- Local variable and method parameter names should comply with a naming convention
- Method names should comply with a naming convention
- Fields in a “Serializable” class should either be transient or serializable
- Classes without “public” constructors should be “final”
- Overriding methods should do more than simply call the same method in the super class
- Static non-final field names should comply with a naming convention
- Utility classes should not have public constructors
- Abstract classes without fields should be converted to interfaces
- @FunctionalInterface annotation should be used to flag Single Abstract Method interfaces
- An abstract class should have both abstract and concrete methods
- “throws” declarations should not be superfluou
- Redundant modifiers should not be used
- Control structures should use curly braces
- Methods should not have too many return statements
- Generic exceptions should never be thrown