Sonarqube Javascript Coverage doesn't show sou

2019-08-30 04:14发布

问题:

I tried to display the coverage from a javascript project with Sonarqube. The value of the code coverage is correct but I can't see the source files.

Currently I have the following project structure:

angular-playground
+- app
|   +- scripts
|   |   +- app.js
+- build
|   +- coverage
|   |   +- lcov.info¨

This is my sonar-project.properties-File:

# metadata
sonar.projectKey=angular-playground
sonar.projectName=angular-playground
sonar.projectVersion=1.0.0

# source folders
sonar.language=js
sonar.sourceEncoding=UTF-8
sonar.sources=app
sonar.tests=test

# coverage reporting
sonar.javascript.lcov.reportPath=build/coverage/lcov.info
sonar.surefire.reportsPath=build/reports/
sonar.dynamicAnalysis=reuseReports

This is my lcov.info-File:

TN:
SF:app/scripts/app.js
FNF:0
FNH:0
DA:11,1
LF:1
LH:1
BRF:0
BRH:0
end_of_record

and the debug log:

SonarQube Runner 2.4
Java 1.8.0_40 Oracle Corporation (64-bit)
Windows 8.1 6.3 amd64
INFO: Error stacktraces are turned on.
INFO: Default locale: "de_CH", source code encoding: "UTF-8"
INFO: SonarQube Server 5.1.1
21:43:29.687 INFO  - Load global repositories
21:43:29.734 DEBUG - Download: http://<domain>/batch/global (no proxy)
21:43:30.273 INFO  - Load global repositories (done) | time=586ms
21:43:30.289 INFO  - Server id: 20150623160836
21:43:30.320 INFO  - Install plugins
21:43:30.320 DEBUG - Download index of plugins
21:43:30.320 DEBUG - Download: http://<domain>/deploy/plugins/index.txt (no proxy)
21:43:30.945 DEBUG - Loaded 3329 properties from l10n bundles
21:43:30.945 INFO  - Install JDBC driver
21:43:30.945 DEBUG - Download index of jdbc-driver
21:43:30.945 DEBUG - Download: http://<domain>/deploy/jdbc-driver.txt (no proxy)
21:43:31.070 INFO  - Create JDBC datasource for jdbc:postgresql://<domain>/sonarqube?useUnicode=true&amp;characterEncoding=utf8
21:43:32.750 DEBUG - Testing JDBC connection
21:43:35.255 DEBUG - Download: http://<domain>/api/server (no proxy)
21:43:35.529 INFO  - Initializing Hibernate
21:43:35.529 DEBUG - hibernate.generate_statistics: false
21:43:35.529 DEBUG - hibernate.dialect: org.sonar.core.persistence.dialect.PostgreSql$PostgreSQLWithDecimalDialect
21:43:35.529 DEBUG - hibernate.connection.provider_class: org.sonar.jpa.session.CustomHibernateConnectionProvider
21:43:39.321 INFO  - Load project repositories
21:43:39.321 DEBUG - Download: http://<domain>/batch/project?key=angular-playground&amp;preview=false (no proxy)
21:43:41.045 INFO  - Load project repositories (done) | time=1724ms
21:43:41.045 INFO  - Load project settings
21:43:41.730 INFO  - Load technical debt model
21:43:41.871 DEBUG - Load technical debt model (done) | time=141ms
21:43:41.885 INFO  - Apply project exclusions
21:43:43.195 WARN  - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
21:43:43.242 DEBUG - Acquire semaphore on project : org.sonar.api.resources.Project@f94fc29[id=<null>,key=angular-playground,qualifier=TRK], with key batch-angular-playground
21:43:43.383 INFO  - -------------  Scan angular-playground
21:43:43.398 INFO  - Load module settings
21:43:43.892 DEBUG - Available languages:
21:43:43.894 DEBUG -   * Java => "java"
21:43:43.894 DEBUG -   * JavaScript => "js"
21:43:44.161 INFO  - Language is forced to js
21:43:44.177 INFO  - Load rules
21:43:53.327 DEBUG - Load rules (done) | time=9150ms
21:43:53.403 DEBUG - Updating semaphore batch-angular-playground
21:43:53.533 DEBUG - Code colorizer, supported languages: 
21:43:53.557 DEBUG - Initializers : 
21:43:53.557 INFO  - Base dir: C:\<cwd>\angular-playground
21:43:53.558 INFO  - Working dir: C:\<cwd>\angular-playground\.sonar
21:43:53.560 INFO  - Source paths: app
21:43:53.561 INFO  - Test paths: test
21:43:53.562 INFO  - Source encoding: UTF-8, default locale: de_CH
21:43:53.563 INFO  - Index files
21:43:53.573 DEBUG - Declared extensions of language org.sonar.batch.repository.language.Language@566140d4 were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
21:43:53.573 DEBUG - Declared extensions of language org.sonar.batch.repository.language.Language@60a8d8d6 were converted to sonar.lang.patterns.js : **/*.js
21:43:53.601 DEBUG - Language of file 'app/scripts/app.js' is detected to be 'js'
21:43:53.614 DEBUG - Language of file 'app/scripts/controllers/main.js' is detected to be 'js'
21:43:53.635 DEBUG - Language of file 'test/karma.ci.conf.js' is detected to be 'js'
21:43:53.642 DEBUG - Language of file 'test/spec/controllers/main.js' is detected to be 'js'
21:43:53.642 DEBUG - Language of file 'test/karma.conf.js' is detected to be 'js'
21:43:53.658 INFO  - 5 files indexed
21:43:56.516 INFO  - Quality profile for js: Sonar way
21:43:57.456 INFO  - JIRA issues sensor will not run as some parameters are missing.
21:43:57.476 DEBUG - Sensors : Lines Sensor (wrapped) -> QProfileSensor -> InitialOpenIssuesSensor -> ProjectLinksSensor -> VersionEventsSensor -> JavaScriptSquidSensor -> SCM Sensor (wrapped) -> org.sonar.plugins.javascript.lcov.UTCoverageSensor@b39a3bf -> org.sonar.plugins.javascript.lcov.ITCoverageSensor@4da6546a -> CPD Sensor (wrapped)
21:43:57.476 INFO  - Sensor Lines Sensor (wrapped)
21:43:57.533 INFO  - Sensor Lines Sensor (wrapped) (done) | time=57ms
21:43:57.534 INFO  - Sensor QProfileSensor
21:43:57.549 INFO  - Sensor QProfileSensor (done) | time=15ms
21:43:57.550 INFO  - Sensor InitialOpenIssuesSensor
21:43:57.655 INFO  - Sensor InitialOpenIssuesSensor (done) | time=105ms
21:43:57.655 INFO  - Sensor ProjectLinksSensor
21:43:57.733 INFO  - Sensor ProjectLinksSensor (done) | time=78ms
21:43:57.733 INFO  - Sensor VersionEventsSensor
21:43:57.920 INFO  - Sensor VersionEventsSensor (done) | time=187ms
21:43:57.921 INFO  - Sensor JavaScriptSquidSensor
21:43:58.952 INFO  - 2 source files to be analyzed
21:43:59.338 INFO  - 2/2 source files analyzed
21:43:59.370 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
21:43:59.385 DEBUG - Metric lines is an internal metric computed by SonarQube. Provided value is ignored.
21:43:59.448 INFO  - Sensor JavaScriptSquidSensor (done) | time=1527ms
21:43:59.448 INFO  - Sensor SCM Sensor (wrapped)
21:43:59.479 INFO  - Sensor SCM Sensor (wrapped) (done) | time=31ms
21:43:59.479 INFO  - Sensor org.sonar.plugins.javascript.lcov.UTCoverageSensor@b39a3bf
21:43:59.479 INFO  - Analysing C:\<cwd>\angular-playground\build\coverage\lcov.info
21:43:59.495 INFO  - Sensor org.sonar.plugins.javascript.lcov.UTCoverageSensor@b39a3bf (done) | time=16ms
21:43:59.495 INFO  - Sensor org.sonar.plugins.javascript.lcov.ITCoverageSensor@4da6546a
21:43:59.495 INFO  - Sensor org.sonar.plugins.javascript.lcov.ITCoverageSensor@4da6546a (done) | time=0ms
21:43:59.495 INFO  - Sensor CPD Sensor (wrapped)
21:43:59.495 INFO  - DefaultCpdEngine is used for js
21:43:59.495 INFO  - Cross-project analysis disabled
21:43:59.510 DEBUG - Populating index from [moduleKey=angular-playground, relative=app/scripts/app.js, basedir=C:\<cwd>\angular-playground]
21:43:59.526 DEBUG - Populating index from [moduleKey=angular-playground, relative=app/scripts/controllers/main.js, basedir=C:\<cwd>\angular-playground]
21:43:59.526 DEBUG - Detection of duplications for [moduleKey=angular-playground, relative=app/scripts/app.js, basedir=C:\<cwd>\angular-playground]
21:43:59.542 DEBUG - Detection of duplications for [moduleKey=angular-playground, relative=app/scripts/controllers/main.js, basedir=C:\<cwd>\angular-playground]
21:43:59.542 INFO  - Sensor CPD Sensor (wrapped) (done) | time=47ms
21:43:59.542 INFO  - No quality gate is configured.
21:44:00.019 INFO  - Compare to previous analysis (2015-06-29)
21:44:00.066 INFO  - Compare over 30 days (2015-05-30, analysis of Fri Jun 26 11:04:54 CEST 2015)
21:44:00.636 INFO  - Execute decorators...
21:44:00.638 DEBUG - Decorators: ManualMeasureDecorator -> org.sonar.batch.issue.tracking.IssueTrackingDecorator@39e05056 -> QProfileEventsDecorator -> org.sonar.batch.design.ProjectDsmDecorator@5eef49f2 -> org.sonar.batch.design.SubProjectDsmDecorator@1376ea26 -> org.sonar.batch.design.DirectoryDsmDecorator@28af6afe -> FileTangleIndexDecorator -> SumDuplicationsDecorator -> UnitTestDecorator -> org.sonar.plugins.core.security.ApplyProjectRolesDecorator@3b5c7033 -> org.sonar.plugins.core.sensors.DirectoriesDecorator@4183a26f -> org.sonar.plugins.core.sensors.FilesDecorator@5bebff4b -> org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister@4ba148fb -> org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer@5811502e -> org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer@6ed80c52 -> org.sonar.plugins.core.timemachine.NewOverallCoverageFileAnalyzer@32144b3c -> org.sonar.plugins.core.timemachine.NewCoverageAggregator@3601fb92 -> f(lines) -> f(generated_lines) -> f(ncloc) -> f(generated_ncloc) -> f(classes) -> f(packages) -> f(functions) -> f(accessors) -> f(statements) -> f(public_api) -> f(comment_lines) -> f(public_undocumented_api) -> f(commented_out_code_lines) -> f(complexity) -> f(complexity_in_classes) -> f(complexity_in_functions) -> f(class_complexity_distribution) -> f(function_complexity_distribution) -> f(file_complexity_distribution) -> f(lines_to_cover) -> f(uncovered_lines) -> f(conditions_to_cover) -> f(uncovered_conditions) -> f(it_lines_to_cover) -> f(it_uncovered_lines) -> f(it_conditions_to_cover) -> f(it_uncovered_conditions) -> f(overall_lines_to_cover) -> f(overall_uncovered_lines) -> f(overall_conditions_to_cover) -> f(overall_uncovered_conditions) -> f(rfc) -> f(rfc_distribution) -> f(lcom4_distribution) -> f(package_cycles) -> f(package_tangles) -> f(package_feedback_edges) -> f(package_edges_weight) -> f(new_lines_to_cover) -> f(new_uncovered_lines) -> f(new_conditions_to_cover) -> f(new_uncovered_conditions) -> f(new_it_lines_to_cover) -> f(new_it_uncovered_lines) -> f(new_it_conditions_to_cover) -> f(new_it_uncovered_conditions) -> f(new_overall_lines_to_cover) -> f(new_overall_uncovered_lines) -> f(new_overall_conditions_to_cover) -> f(new_overall_uncovered_conditions) -> org.sonar.batch.language.LanguageDistributionDecorator@454009a0 -> org.sonar.batch.debt.DebtDecorator@483740d5 -> org.sonar.batch.debt.NewDebtDecorator@24e25991 -> DirectoryTangleIndexDecorator -> org.sonar.batch.cpd.decorators.DuplicationDensityDecorator@4d763525 -> CountUnresolvedIssuesDecorator -> CountFalsePositivesDecorator -> CommentDensityDecorator -> f(file_complexity) -> f(class_complexity) -> f(function_complexity) -> org.sonar.plugins.core.sensors.LineCoverageDecorator@78751d07 -> org.sonar.plugins.core.sensors.CoverageDecorator@2d34798d -> org.sonar.plugins.core.sensors.BranchCoverageDecorator@53f92771 -> org.sonar.plugins.core.sensors.ItLineCoverageDecorator@6160714c -> org.sonar.plugins.core.sensors.ItCoverageDecorator@31add542 -> org.sonar.plugins.core.sensors.ItBranchCoverageDecorator@3f5b2aeb -> org.sonar.plugins.core.sensors.OverallLineCoverageDecorator@258350de -> org.sonar.plugins.core.sensors.OverallCoverageDecorator@478bbf33 -> org.sonar.plugins.core.sensors.OverallBranchCoverageDecorator@18537545 -> org.sonar.batch.debt.SqaleRatingDecorator@79f40cc5 -> org.sonar.plugins.core.timemachine.TendencyDecorator@4cf4fb3b -> VariationDecorator
21:44:03.511 DEBUG - Updating semaphore batch-angular-playground
21:44:04.137 DEBUG - Decorator time:
    ManualMeasureDecorator: 289ms
    org.sonar.batch.issue.tracking.IssueTrackingDecorator@39e05056: 13ms
    QProfileEventsDecorator: 173ms
    org.sonar.batch.design.ProjectDsmDecorator@5eef49f2: 1ms
    org.sonar.batch.design.SubProjectDsmDecorator@1376ea26: 1ms
    org.sonar.batch.design.DirectoryDsmDecorator@28af6afe: 16ms
    FileTangleIndexDecorator: 9ms
    SumDuplicationsDecorator: 1ms
    UnitTestDecorator: 1ms
    org.sonar.plugins.core.security.ApplyProjectRolesDecorator@3b5c7033: 127ms
    org.sonar.plugins.core.sensors.DirectoriesDecorator@4183a26f: 0ms
    org.sonar.plugins.core.sensors.FilesDecorator@5bebff4b: 1ms
    org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister@4ba148fb: 606ms
    org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer@5811502e: 34ms
    org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer@6ed80c52: 0ms
    org.sonar.plugins.core.timemachine.NewOverallCoverageFileAnalyzer@32144b3c: 0ms
    org.sonar.plugins.core.timemachine.NewCoverageAggregator@3601fb92: 1ms
    f(lines): 1ms
    f(generated_lines): 2ms
    f(ncloc): 0ms
    f(generated_ncloc): 1ms
    f(classes): 0ms
    f(packages): 0ms
    f(functions): 0ms
    f(accessors): 0ms
    f(statements): 0ms
    f(public_api): 0ms
    f(comment_lines): 0ms
    f(public_undocumented_api): 0ms
    f(commented_out_code_lines): 0ms
    f(complexity): 0ms
    f(complexity_in_classes): 0ms
    f(complexity_in_functions): 0ms
    f(class_complexity_distribution): 0ms
    f(function_complexity_distribution): 1ms
    f(file_complexity_distribution): 1ms
    f(lines_to_cover): 1ms
    f(uncovered_lines): 0ms
    f(conditions_to_cover): 0ms
    f(uncovered_conditions): 0ms
    f(it_lines_to_cover): 1ms
    f(it_uncovered_lines): 0ms
    f(it_conditions_to_cover): 0ms
    f(it_uncovered_conditions): 0ms
    f(overall_lines_to_cover): 0ms
    f(overall_uncovered_lines): 0ms
    f(overall_conditions_to_cover): 0ms
    f(overall_uncovered_conditions): 0ms
    f(rfc): 0ms
    f(rfc_distribution): 0ms
    f(lcom4_distribution): 0ms
    f(package_cycles): 0ms
    f(package_tangles): 0ms
    f(package_feedback_edges): 0ms
    f(package_edges_weight): 0ms
    f(new_lines_to_cover): 0ms
    f(new_uncovered_lines): 0ms
    f(new_conditions_to_cover): 0ms
    f(new_uncovered_conditions): 0ms
    f(new_it_lines_to_cover): 0ms
    f(new_it_uncovered_lines): 0ms
    f(new_it_conditions_to_cover): 0ms
    f(new_it_uncovered_conditions): 0ms
    f(new_overall_lines_to_cover): 0ms
    f(new_overall_uncovered_lines): 0ms
    f(new_overall_conditions_to_cover): 1ms
    f(new_overall_uncovered_conditions): 0ms
    org.sonar.batch.language.LanguageDistributionDecorator@454009a0: 2ms
    org.sonar.batch.debt.DebtDecorator@483740d5: 11ms
    org.sonar.batch.debt.NewDebtDecorator@24e25991: 5ms
    DirectoryTangleIndexDecorator: 0ms
    org.sonar.batch.cpd.decorators.DuplicationDensityDecorator@4d763525: 0ms
    CountUnresolvedIssuesDecorator: 55ms
    CountFalsePositivesDecorator: 2ms
    CommentDensityDecorator: 0ms
    f(file_complexity): 0ms
    f(class_complexity): 0ms
    f(function_complexity): 0ms
    org.sonar.plugins.core.sensors.LineCoverageDecorator@78751d07: 8ms
    org.sonar.plugins.core.sensors.CoverageDecorator@2d34798d: 0ms
    org.sonar.plugins.core.sensors.BranchCoverageDecorator@53f92771: 1ms
    org.sonar.plugins.core.sensors.ItLineCoverageDecorator@6160714c: 0ms
    org.sonar.plugins.core.sensors.ItCoverageDecorator@31add542: 0ms
    org.sonar.plugins.core.sensors.ItBranchCoverageDecorator@3f5b2aeb: 0ms
    org.sonar.plugins.core.sensors.OverallLineCoverageDecorator@258350de: 0ms
    org.sonar.plugins.core.sensors.OverallCoverageDecorator@478bbf33: 1ms
    org.sonar.plugins.core.sensors.OverallBranchCoverageDecorator@18537545: 0ms
    org.sonar.batch.debt.SqaleRatingDecorator@79f40cc5: 5ms
    org.sonar.plugins.core.timemachine.TendencyDecorator@4cf4fb3b: 1032ms
    VariationDecorator: 941ms

21:44:04.138 INFO  - Store results in database
21:44:04.140 DEBUG - Execute org.sonar.batch.phases.GraphPersister
21:44:04.165 DEBUG - Execute org.sonar.batch.index.SourcePersister
21:44:04.494 DEBUG - Execute org.sonar.batch.index.ResourcePersister
21:44:04.494 DEBUG - Execute org.sonar.batch.index.MeasurePersister
21:44:06.450 DEBUG - Execute org.sonar.batch.index.DuplicationPersister
21:44:06.600 INFO  - Analysis reports generated in 135ms, dir size=767 bytes
21:44:06.678 INFO  - Analysis reports compressed in 63ms, zip size=3 KB
21:44:06.678 DEBUG - Publish results
21:44:06.945 INFO  - Analysis reports sent to server in 266ms
21:44:06.945 INFO  - ANALYSIS SUCCESSFUL, you can browse http://<domain>/dashboard/index/angular-playground
21:44:06.945 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
21:44:06.947 DEBUG - Post-jobs : 
21:44:06.948 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@f94fc29[id=75,key=angular-playground,qualifier=TRK], with key batch-angular-playground
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 39.758s
Final Memory: 20M/469M
INFO: ------------------------------------------------------------------------

When the path to the source file is incorrect ./app/scripts/app.js then I see the source file but not the correct coverage value. I use Sonar 5.1.1 and the javascript plugin 2.6.

Is this a bug with the javascript plugin or a configuration fault?

回答1:

Your configuration is ok. The problem in UI: it lists only files with uncovered lines. As you don't have them - nothing is listed. But you still can browse your files through other metrics (files, lines) or "Components" page.