声纳分析PHP项目的问题

时间:2012-04-12 14:03:36

标签: php phpunit sonarqube

我想用声纳分析一个PHP项目。我安装了PHP-Plugin和PHPunit,并创建了一个包含所有必要信息的sonar-project.properties文件。我使用Java-runner执行。我已经为我的问题尝试了数百种可能的解决方案,但没有任我总是得到这个错误:

Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: org.sonar.api.utils.SonarException: Can't read PhpUnit report : /var/www/smc/.sonar/target/logs/phpunit.xml
        at org.sonar.runner.Runner.delegateExecution(Runner.java:189)
        at org.sonar.runner.Runner.execute(Runner.java:78)
        at org.sonar.runner.Main.main(Main.java:61)
Caused by: org.sonar.api.utils.SonarException: Can't read PhpUnit report : /var/www/smc/.sonar/target/logs/phpunit.xml
        at org.sonar.plugins.php.phpunit.PhpUnitResultParser.getTestSuites(PhpUnitResultParser.java:103)
        at org.sonar.plugins.php.phpunit.PhpUnitResultParser.parseFile(PhpUnitResultParser.java:158)
        at org.sonar.plugins.php.phpunit.PhpUnitResultParser.parse(PhpUnitResultParser.java:145)
        at org.sonar.plugins.php.phpunit.PhpUnitSensor.analyse(PhpUnitSensor.java:72)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
        at org.sonar.batch.phases.Phases.execute(Phases.java:93)
        at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:143)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:115)
        at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:105)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:102)
        at org.sonar.batch.bootstrap.Module.start(Module.java:83)
        at org.sonar.batch.Batch.execute(Batch.java:104)
        at org.sonar.runner.Launcher.executeBatch(Launcher.java:65)
        at org.sonar.runner.Launcher.execute(Launcher.java:58)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.sonar.runner.Runner.delegateExecution(Runner.java:186)
        ... 2 more
Caused by: java.io.FileNotFoundException: /var/www/smc/.sonar/target/logs/phpunit.xml (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:120)
        at org.sonar.plugins.php.phpunit.PhpUnitResultParser.getTestSuites(PhpUnitResultParser.java:98)
        ... 22 more

这是我的属性文件:

# required metadata
sonar.projectKey=my:project
sonar.projectName=Social Media Connector
sonar.projectVersion=1.0

# path to source directories (required)
sources=htdocs/website/controllers

# path to test source directories (optional)
#tests=htdocs/website/controllers/tests
#sonar.phpUnit.mainTestClass=htdocs/website/controllers/tests/website/controllers/blubbTest.php

# path to project binaries (optional), for example directory of Java bytecode
#binaries=binDir

# optional comma-separated list of paths to libraries. Only path to JAR file and path to directory of classes are supported.
#libraries=path/to/library.jar,path/to/classes/dir


# Uncomment those lines if some features of java 5 or java 6 like annotations, enum, ...
# are used in the source code to be analyzed
#sonar.java.source=1.5
#sonar.java.target=1.5


# Uncomment this line to analyses a project which is not a java project.
# The value of the property must be the key of the language.
sonar.language=php

# Advanced parameters
#my.property=value
#sonar.phpUnit.skip=true
sonar.phpUnit.analyze.test.directory=true

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

原始错误在这里:

  

引起:java.io.FileNotFoundException:/var/www/smc/.sonar/target/logs/phpunit.xml(没有这样的文件或目录)

确保找到文件/var/www/smc/.sonar/target/logs/phpunit.xml