我目前正在努力尝试覆盖范围,

覆盖文件(cobertura xml)在指定的 target 目录上正确生成,然后在 sonar.python.coverage.reportPath (基于我的父pom文件)上指定 . 顶级是父pom和不同的目录(包) .

这就是 module-test 的pom的pom属性

<sonar.inclusions>**/python/*/*.py</sonar.inclusions>
<sonar.exclusions>**/python/*/__init__.py</sonar.exclusions>
<sonar.language>py</sonar.language>
<sonar.python.coverage.reportPath>target/cov-report/cov-report.xml</sonar.python.coverage.reportPath>

可能是因为夹杂物阻止它被添加?我目前设置它,以便声纳只分析我们的基本文件 .

这是项目结构:

module-a
    src
        python
    target  
module-b
    src
       python
    target  
module-c
    src
       python
    target  
module-test
    src
       python
           functionA
           functionB
       unit_test.py
    target
        cov-report
            cov-report.xml
    pom.xml
pom.xml


[WARNING] JUnit report directory not found at 
/home/jenkins/workspace/master-ASDASKDOKAOK/module-test/sonar-reports
[INFO] Sensor Swift Surefire Sensor (done) | time=0ms
[INFO] Sensor SCM Sensor
[INFO] Sensor SCM Sensor (done) | time=1ms
[INFO] Sensor Python Squid Sensor
[INFO] Python unit test coverage
[INFO] Parsing report '/home/jenkins/workspace/master-ASDASKDOKAOK/module-test/target/cov-report/cov-report.xml'
[INFO] Python integration test coverage
[INFO] Python overall test coverage
[INFO] Sensor Python Squid Sensor (done) | time=1311ms
[INFO] Sensor XmlFileSensor
[INFO] Sensor XmlFileSensor (done) | time=0ms
[INFO] Sensor Analyzer for "php.ini" files
[INFO] Sensor Analyzer for "php.ini" files (done) | time=0ms
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=9ms
[INFO] Sensor Code Colorizer Sensor
[INFO] Sensor Code Colorizer Sensor (done) | time=0ms
[INFO] Sensor CPD Block Indexer
[INFO] DefaultCpdBlockIndexer is used for py
[INFO] Sensor CPD Block Indexer (done) | time=52ms

声纳版本是sonar-python-plugin-1.8.0.1496