Как настроить SonarQube для проекта AngularJS на основе Typescript?

Я установил SonarQube и SonarScanner, и мне удалось просканировать свой проект. Я вижу на экране показатели, за исключением покрытия кода, которое всегда равно 0%. Что мне не хватает?

#----- Default SonarQube server
sonar.host.url=http://localhost:9000/sonar

#----- Default source code encoding
#sonar.sourceEncoding=UTF-8

# must be unique in a given SonarQube instance
sonar.projectKey=pwta
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=PWTA
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=client

sonar.language=ts
sonar.exclusions=**/node_modules/**
sonar.typescript.lcov.reportPaths=coverage/lcov.info

Это отрывок из файла sonar-project.properties. И файл LCOV, расположенный в extension / lcov.info, был создан с использованием библиотеки nyc.

введите описание изображения здесь

Журналы из командной строки:

INFO: Scanner configuration file: NONE
INFO: Project root configuration file: C:\Repos\pwta-desktop\ui\sonar-project.properties
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\koklliew\.sonar\cache
INFO: SonarQube server 7.6.0
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=90ms
INFO: Server id: 9CFC3560-AWmQJqPmStMXNHgIIeVs
INFO: User cache: C:\Users\koklliew\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=166ms
INFO: Load/download plugins (done) | time=223ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=4ms
INFO: Project key: pwta
INFO: Base dir: C:\Repos\pwta-desktop\ui
INFO: Working dir: C:\Repos\pwta-desktop\ui\.scannerwork
INFO: Load project settings
INFO: Load project settings (done) | time=49ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=156ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=46ms
INFO: Load active rules
INFO: Load active rules (done) | time=802ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=36ms
INFO: Language is forced to ts
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/node_modules/**, *.spec.ts
INFO:   Included tests: *.spec.ts
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\app.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\app.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\backend\database\seeders\guiSettings.json' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\display-settings\display-settings-group\display-settings-group.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\display-settings\display-settings-tabs\display-settings-tabs.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\display-settings\display-settings.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\display-settings\display-settings.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\external-params-editor\external-params-editor.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\external-params-editor\external-params-editor.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\external-params.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\external-params.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\merge-external-params\merge-external-params.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\merge-external-params\merge-external-params.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\_external-params-global.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\_mixins.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\external-params\_variables.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\hidden-elements\hidden-elements.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\hidden-elements\hidden-elements.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\incompatible-testPlan-dialog\incompatible-testPlan-dialog.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\incompatible-testPlan-dialog\incompatible-testPlan-dialog.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\interaction-dialog\interaction-dialog.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\interaction-dialog\interaction-dialog.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\menu\menu.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\menu\menu.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\navigation-bar\navigation-bar.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\navigation-bar\navigation-bar.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notification-area\notification-area.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notification-area\notification-area.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-resource\notifications-resource.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-resource\notifications-resource.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-resource\overlay\overlay.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-resource\overlay\overlay.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-toolbar\filter\notification-filter.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-toolbar\filter\notification-filter.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-toolbar\notifications-toolbar.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-toolbar\notifications-toolbar.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-toolbar\search\notifications-search.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\notifications-toolbar\search\notifications-search.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\package-manager-dialog\directives\pm-extended.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\package-manager-dialog\package-manager-dialog.component.html' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\package-manager-dialog\package-manager-dialog.component.scss' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\property-editor\DisplayForProps.tsd.json' is ignored because it doesn't belong to the forced language 'ts'
WARN: File 'C:\Repos\pwta-desktop\ui\client\app\components\property-editor\DisplayForPropsTree.json' is ignored because it doesn't belong to the forced language 'ts'

... продолжается ...

INFO: 343 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for ts: Sonar way
INFO: ------------- Run sensors on module PWTA
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=12ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=9ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=20ms
INFO: Sensor SonarTS [typescript]
INFO: Analyzing 343 typescript file(s) with the following configuration file C:\Repos\pwta-desktop\ui\tsconfig.json
INFO: 145 files analyzed out of 343. Current file: C:\Repos\pwta-desktop\ui\client\app\components\sequence-viewer\services\results-utility.service.spec.ts
INFO: 343 files analyzed out of 343
INFO: Sensor SonarTS [typescript] (done) | time=38926ms
INFO: Sensor SonarTS Coverage [typescript]
INFO: Analysing [C:\Repos\pwta-desktop\ui\coverage\lcov.info]
WARN: Could not resolve 1 file paths in [C:\Repos\pwta-desktop\ui\coverage\lcov.info], first unresolved path: c:\repos\pwta-desktop\ui\karma.conf.js
INFO: Sensor SonarTS Coverage [typescript] (done) | time=14ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=248ms
INFO: ------------- Run sensors on project
INFO: SCM provider for this project is: git
INFO: 1 files to be analyzed
INFO: 0/1 files analyzed
WARN: Missing blame information for the following files:
WARN:   * client/version.ts
WARN: This may lead to missing/broken features in SonarQube
INFO: 43 files had no CPD blocks
INFO: Calculating CPD for 300 files
INFO: CPD calculation finished
INFO: Analysis report generated in 3904ms, dir size=2 MB
INFO: Analysis report compressed in 3421ms, zip size=1 MB
INFO: Analysis report uploaded in 145ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/sonar/dashboard?id=pwta
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/sonar/api/ce/task?id=AWmkhBxOhYEp7lx6Lmb2
INFO: Analysis total time: 1:01.823 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:04.060s
INFO: Final Memory: 19M/407M
INFO: ------------------------------------------------------------------------

Журнал показывает, что он может найти файл lcov.

И, похоже, есть жалоба, в которой упоминается путь в журнале выше. Может быть проблема?


person oatcrunch    schedule 22.03.2019    source источник


Ответы (1)


Я думаю, что ваш путь lcov.info неверен в вашем sonar-project.properties. Это мое:

# TypeScript specific config
sonar.typescript.lcov.reportPaths=coverage/my-project/lcov.info
sonar.test.inclusions=**/*.spec.ts
person Lexalis    schedule 10.07.2019
comment
Лично я использовал клавишу sonar.javascript.lcov.reportPaths (type против java) с SonarQube Community Edition версии 7.9.2. - person Julien; 17.08.2020
comment
С sonar.typescript.lcov.reportPaths я получил WARN: The use of sonar.typescript.lcov.reportPaths for coverage import is deprecated, use sonar.javascript.lcov.reportPaths instead. - person DaveO; 23.01.2021