当我启动./gradlew sonar
它运行分析器并加载文件时,项目将添加到sonarqube数据库中,包含文件列表,复杂性等,但不会为项目创建任何问题。 Android Lint(已添加147条规则)被设置为问题的默认列表,SonarQube方式被设置为默认(且仅限)质量门。
完整日志:
sudokusolver git:(master) ✗ ./gradlew sonar
:app:sonarqube
INFO: Default locale: "en_GB", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Work directory: /home/agilob/Projects/sudokusolver/app/build/sonar
INFO: SonarQube Server 5.1.2
11:48:48.324 INFO - Load global repositories
11:48:48.552 INFO - Load global repositories (done) | time=234ms
11:48:48.554 INFO - Server id: 20150807203003
11:48:48.557 INFO - User cache: /home/agilob/.sonar/cache
11:48:48.565 INFO - Install plugins
11:48:48.949 INFO - Install JDBC driver
11:48:48.962 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
11:48:50.575 INFO - Initializing Hibernate
11:48:52.689 INFO - Load project repositories
11:48:52.925 INFO - Load project repositories (done) | time=236ms
11:48:52.926 INFO - Load project settings
11:48:53.265 INFO - Load technical debt model
11:48:53.299 INFO - Apply project exclusions
11:48:53.555 WARN - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
11:48:53.574 WARN - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.
11:48:53.576 INFO - ------------- Scan SudokuSolver
11:48:53.583 INFO - Load module settings
11:48:53.727 INFO - Language is forced to java
11:48:53.739 INFO - Load rules
11:48:54.981 INFO - Base dir: /home/agilob/Projects/sudokusolver/app
11:48:54.981 INFO - Working dir: /home/agilob/Projects/sudokusolver/app/build/sonar
11:48:54.982 INFO - Source paths: src/main
11:48:54.982 INFO - Test paths: src/androidTest
11:48:54.983 INFO - Source encoding: UTF-8, default locale: en_GB
11:48:54.983 INFO - Index files
11:48:55.116 INFO - 35 files indexed
11:48:55.304 INFO - Quality profile for java: Android Lint
11:48:55.511 WARN - ----------------------------------------------------------------
11:48:55.512 WARN - Sonargraph: Skipping projectSudokuSolver [SusokuSolver], since no Sonargraph rules are activated in current SonarQube quality profile.
11:48:55.512 WARN - ----------------------------------------------------------------
11:48:55.512 INFO - Trying to guess scm provider from project layout...
11:48:55.513 INFO - Found SCM type: git
11:48:55.523 INFO - Sensor JavaSquidSensor
11:48:56.119 INFO - Java Main Files AST scan...
11:48:56.122 INFO - 34 source files to be analyzed
11:48:59.551 INFO - Java Main Files AST scan done: 3432 ms
11:48:59.552 INFO - 34/34 source files have been analyzed
11:48:59.552 WARN - Java bytecode has not been made available to the analyzer. The org.sonar.java.bytecode.visitor.DependenciesVisitor@6e61d22c are disabled.
11:48:59.553 INFO - Java Test Files AST scan...
11:48:59.553 INFO - 1 source files to be analyzed
11:48:59.653 INFO - Java Test Files AST scan done: 100 ms
11:48:59.653 INFO - 1/1 source files have been analyzed
11:48:59.660 INFO - Sensor JavaSquidSensor (done) | time=4137ms
11:48:59.660 INFO - Sensor Lines Sensor
11:48:59.673 INFO - Sensor Lines Sensor (done) | time=13ms
11:48:59.674 INFO - Sensor QProfileSensor
11:48:59.680 INFO - Sensor QProfileSensor (done) | time=6ms
11:48:59.680 INFO - Sensor InitialOpenIssuesSensor
11:48:59.689 INFO - Sensor InitialOpenIssuesSensor (done) | time=9ms
11:48:59.689 INFO - Sensor ProjectLinksSensor
11:48:59.701 INFO - Sensor ProjectLinksSensor (done) | time=12ms
11:48:59.702 INFO - Sensor VersionEventsSensor
11:48:59.721 INFO - Sensor VersionEventsSensor (done) | time=19ms
11:48:59.722 INFO - Sensor SurefireSensor
11:48:59.723 INFO - parsing /home/agilob/Projects/sudokusolver/app/target/surefire-reports
11:48:59.724 ERROR - Reports path not found or is not a directory: /home/agilob/Projects/sudokusolver/app/target/surefire-reports
11:48:59.724 INFO - Sensor SurefireSensor (done) | time=2ms
11:48:59.725 INFO - Sensor ScmStatsSensor
11:48:59.726 INFO - Collection SCM Change log for the last 0 days
11:48:59.773 INFO - Executing: /bin/sh -c cd /home/agilob/Projects/sudokusolver/app && git whatchanged '--until=2015-08-08 10:48:59 +0000' --date=iso -- /home/agilob/Projects/sudokusolver/app
11:48:59.774 INFO - Working directory: /home/agilob/Projects/sudokusolver/app
11:49:00.107 INFO - Sensor ScmStatsSensor (done) | time=382ms
11:49:00.107 INFO - Sensor SCM Sensor
11:49:00.108 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
11:49:00.108 INFO - Sensor SCM Sensor (done) | time=1ms
11:49:00.108 INFO - Sensor CPD Sensor
11:49:00.109 INFO - JavaCpdEngine is used for java
11:49:00.110 INFO - Cross-project analysis disabled
11:49:00.395 INFO - Sensor CPD Sensor (done) | time=287ms
11:49:00.419 INFO - Loaded quality gate 'SonarQube way'
11:49:00.456 INFO - Compare to previous analysis (2015-08-08)
11:49:00.458 INFO - Compare over 30 days (2015-07-09, analysis of Fri Aug 07 23:19:57 BST 2015)
11:49:01.391 INFO - Execute decorators...
11:49:02.036 INFO - Store results in database
11:49:02.904 INFO - Analysis reports generated in 24ms, dir size=4 KB
11:49:02.934 INFO - Analysis reports compressed in 30ms, zip size=14 KB
11:49:02.964 INFO - Analysis reports sent to server in 30ms
11:49:02.964 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/SusokuSolver
11:49:02.964 INFO - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
BUILD SUCCESSFUL
Total time: 24.204 secs
我的配置已添加到主gradle.build
buildscript {
dependencies {
classpath "org.sonarqube.gradle:gradle-sonarqube-plugin:1.0"
}
}
我的配置已添加到app/gradle.build
apply plugin: "org.sonarqube"
sonarqube {
properties {
property "sonar.projectName", "SudokuSolver"
property "sonar.projectKey", "SusokuSolver"
property "sonar.host.url", "http://localhost:9000"
property "sonar.projectVersion", "1.0"
property "sonar.language", "java"
property "sonar.sources", "src/main/"
property "sonar.tests", "src/androidTest/"
}
}
SonarQube是在嵌入式数据库上推出的,仅供测试,但我认为不重要。
当我在IDEA中启动代码分析器时,在> 60秒后,它会给我50多条消息。我什么都没得到。
答案 0 :(得分:1)
感兴趣的是,我写了一篇关于它的a short blog post,它比这个答案更新。
好的,我解决了这个问题。如果您遇到同样的问题,您必须在您的机器上安装mysql / postgress服务器,为SonarQube创建数据库和用户,并且app/build.gradle
中的配置必须如下所示(我使用的是MariaDB服务器):
sonarqube {
properties {
property "sonar.projectName", "SudokuSolver"
property "sonar.projectKey", "SudokuSolver"
property "sonar.host.url", "http://localhost:9000"
property "sonar.jdbc.url", "jdbc:mysql://localhost:3306/sonar"
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", "SONAR_LOGIN"
property "sonar.jdbc.password", "SONAR_PASSWORD"
property "sonar.projectVersion", "1.0"
property "sonar.language", "java"
property "sonar.sources", "src/main/"
property "sonar.tests", "src/androidTest/"
property "sonar.scm.provider", "git"
}
}