0

我有一个 Kotlin 项目,我正在尝试使用 SonarQube 进行分析,但在使用 sonar-scanner 运行分析后,我没有在 SonarQube 上获得任何输出。

这是我的 sonar-scanner.properties 文件的样子:

sonar.projectKey=my:Project
sonar.projectName=MyProject
sonar.projectVersion=1.0

这是在我的根目录中运行“sonar-scanner”命令的输出:

INFO: Scanner configuration file: /opt/sonarscanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /Users/mshah134/Documents/Clients/sonar-project.properties
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Mac OS X 10.14.6 x86_64
INFO: User cache: /Users/mshah134/.sonar/cache
INFO: SonarQube server 8.0.0
INFO: Default locale: "en_AE", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=41ms
INFO: Server id: BF41A1F2-AW5-Bdo2nCvd9XLOhxPQ
INFO: User cache: /Users/mshah134/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=31ms
INFO: Load/download plugins (done) | time=76ms
INFO: Process project properties
INFO: Process project properties (done) | time=1ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: my:Project
INFO: Base dir: /Users/mshah134/Documents/Clients/
INFO: Working dir: /Users/mshah134/Documents/Clients/.scannerwork
INFO: Load project settings for component key: 'my:Project'
INFO: Load project settings for component key: 'my:Project' (done) | time=11ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=31ms
INFO: Load active rules
INFO: Load active rules (done) | time=1018ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 806 files indexed
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for kotlin: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module MyProject
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=19ms
INFO: Using JAXBContext implementation: com.sun.xml.bind.v2.runtime.JAXBContextImpl
INFO: Sonargraph Integration: Custom metrics file '/Users/mshah134/.sonargraphintegration/metrics.properties' not found
INFO: Sonargraph Integration: Created 53 predefined and 0 custom metric(s)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/Users/mshah134/.sonar/cache/866bb1adbf016ea515620f1aaa15ec53/sonar-javascript-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=5ms
INFO: Sensor Kotlin Sensor [kotlin]
INFO: 305 source files to be analyzed
INFO: Load project repositories
INFO: Load project repositories (done) | time=8ms
INFO: Sensor Kotlin Sensor [kotlin] (done) | time=3815ms
INFO: 305/305 source files have been analyzed
INFO: Sensor JavaXmlSensor [java]
INFO: 290 source files to be analyzed
INFO: Sensor JavaXmlSensor [java] (done) | time=1077ms
INFO: 290/290 source files have been analyzed
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=351ms
INFO: Sensor XML Sensor [xml]
INFO: 290 source files to be analyzed
INFO: Sensor XML Sensor [xml] (done) | time=888ms
INFO: 290/290 source files have been analyzed
INFO: Sensor Sonargraph Integration [sonargraphintegration]
INFO: Sonargraph Integration: Processing SonarQube project 'my:Project'
WARN: Sonargraph Integration: XML report file '/Users/mshah134/Documents/Clients/target/sonargraph/sonargraph-sonarqube-report.xml' not found
INFO: Sonargraph Integration: Finished processing SonarQube project 'my:Project'
INFO: Sensor Sonargraph Integration [sonargraphintegration] (done) | time=0ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=78ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 596 source files to be analyzed
INFO: SCM Publisher 594/596 source files have been analyzed (done) | time=3632ms
WARN: Missing blame information for the following files:
WARN:   * HTML_Report.html
WARN:   * XML_Report.xml
WARN: This may lead to missing/broken features in SonarQube
INFO: CPD Executor 57 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 249 files
INFO: CPD Executor CPD calculation finished (done) | time=108ms
INFO: Analysis report generated in 284ms, dir size=3 MB
INFO: Analysis report compressed in 1236ms, zip size=1 MB
INFO: Analysis report uploaded in 87ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=my%3AProject
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AW6MaqELqw9TfdaFvBVY
INFO: Analysis total time: 16.050 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 16.766s
INFO: Final Memory: 15M/64M
INFO: ------------------------------------------------------------------------

但是,在 SonarQube 上,我只看到以下内容:

在此处输入图像描述

这是我在后台任务页面上得到的:

在此处输入图像描述

这是我单击“显示扫描仪上下文”选项时得到的输出:

SonarQube plugins:
  - SonarPython 1.16.0.4432 (python)
  - SonarCSS 1.1.1.1010 (cssfamily)
  - JaCoCo 1.0.2.475 (jacoco)
  - SonarGo 1.6.0.719 (go)
  - SonarKotlin 1.5.0.315 (kotlin)
  - Swift (Backelite) 0.4.5 (backelitesonarswiftplugin)
  - 3D Code Metrics 3.7 (citymodel)
  - Svn 1.9.0.1295 (scmsvn)
  - SonarJS 5.2.1.7778 (javascript)
  - SonarRuby 1.5.0.315 (ruby)
  - SonarScala 1.5.0.315 (sonarscala)
  - SonarC# 7.17.0.9346 (csharp)
  - SonarJava 5.14.0.18788 (java)
  - Sonargraph Integration 4.0.0 (sonargraphintegration)
  - SonarHTML 3.2.0.2082 (web)
  - Git 1.9.1.1834 (scmgit)
  - SonarFlex 2.5.1.1831 (flex)
  - SonarXML 2.0.1.2020 (xml)
  - SonarPHP 3.2.0.4868 (php)
  - SonarTS 1.9.0.3766 (typescript)
  - SonarVB 7.17.0.9346 (vbnet)
Global server settings:
  - sonar.core.id=BF41A1F2-AW5-Bdo2nCvd9XLOhxPQ
  - sonar.core.startTime=2019-11-21T09:00:08+0400
Project server settings:
Project scanner properties:
  - sonar.host.url=http://localhost:9000
  - sonar.projectBaseDir=/Users/mshah134/Documents/Clients/
  - sonar.projectKey=my:Project
  - sonar.projectName=MyProject
  - sonar.projectVersion=1.0
  - sonar.scanner.app=ScannerCli
  - sonar.scanner.appVersion=4.2.0.1873
  - sonar.sourceEncoding=UTF-8
  - sonar.working.directory=/Users/mshah134/Documents/Clients/.scannerwork
4

1 回答 1

1

弄清楚了。

基本上这是一个权限问题。

我最初在 /opt 中安装了 sonar-qube 和声纳扫描仪。当我从另一个目录运行声纳扫描仪时,将文件推送到本地 sonar-qube 服务器时出现问题。

我从 /etc/paths 中删除了 sonar-scanner 条目,并将所有 sonarqube 和 sonarscanner 文件放在 ~/Documents 文件夹中。

然后我在文件夹上递归地执行了 chmod,在 /etc/paths 中重新添加了 sonar-scanner 的新位置,并再次启动了 sonar-qube 服务器。

那时一切都很好。:)

于 2019-11-21T08:26:30.593 回答