2

我正在尝试声纳,我在一个 php 项目中遇到了一些问题。

我必须做多模块才能至少获得 php 和 js 分析。

这是我的声纳项目.properties:

sonar.projectKey=xxxx sonar.projectName=xxxx sonar.projectVersion=1.0

sonar.sourceEncoding=UTF-8
sonar.sources=
sonar.language=php
sonar.exclusions=htdocs/libraries/externals/**
sonar.phpCodesniffer.skip=true

sonar.modules=php-module,js-module

# PHP module
php-module.sonar.projectName=PHP Module
php-module.sonar.language=php
php-module.sonar.sources=
php-module.sonar.projectBaseDir=htdocs
php-module.sonar.exclusions=libraries/externals/**

# JavaScript module
js-module.sonar.projectName=JavaScript Module
js-module.sonar.language=js
js-module.sonar.sources=js
js-module.sonar.projectBaseDir=htdocs

但是当我运行 sonar-runner 时,我得到了这个错误:

Exception in thread "main" org.sonar.runner.RunnerException: org.sonar.api.utils.SonarException: PHPMD execution failed with returned code '1'. Please check the documentation of PHPMD to know more about this failure

PHPMD 错误是

 The parser has reached an invalid state near line "32" in file "/var/www/vhosts/dev3.xxxx.local/htdocs/libraries/externals/AvaTax4PHP/classes/ATConfig.class.php". Please check the following conditions: The keyword "parent" was used as type hint but the class "ATConfig" does not declare a parent.

但是,如果我排除了项目和模块中的目录库,为什么会发生这种情况?

我是否必须向 PHPMD 指定另一个排除列表?

4

2 回答 2

3

对于 PHPMD(例如 PHP CodeSniffer),您必须指定一个单独的排除模式。您可以为此使用 PHPMD 的--exclude参数。

花了我一段时间才弄清楚,但您可以在sonar-project.properties文件中使用以下设置来设置 PHPMD 的命令行参数:

sonar.phpPmd.argumentLine=--exclude libraries/externals
于 2013-05-19T19:13:48.053 回答
1

您可以参考此常见问题解答条目以了解如何实现您的目标:http ://docs.codehaus.org/display/SONAR/PHP+Plugin+FAQ#PHPPluginFAQ-HowdoIpreventexternaltoolsfromanalyzingsomesourcefiles

顺便说一句,您应该声明:

php-module.sonar.sources=.

, 代替:

php-module.sonar.sources=
于 2013-03-11T12:39:25.090 回答