You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Sonar Scanner扫描Drupal模块根目录的.module文件

解决Drupal模块根目录.module文件未被SonarQube扫描的问题

你的问题核心在于sonar.sources的配置范围——当前只指定了子目录inc,modules,templates,没有包含模块的根目录,所以根目录下的.module文件没被纳入扫描范围。

只需要做一处简单修改:把.(代表当前模块的根目录)添加到sonar.sources的列表中,这样就能同时覆盖根目录和指定子目录下所有符合后缀规则的文件了。

修改后的完整sonar-project.properties配置如下:

# Root project information
sonar.projectKey=MyProjectKey
sonar.projectName=My Project
sonar.projectVersion=1.0

# Some properties that will be inherited by the modules
sonar.sources=.,inc,modules,templates  # 新增`.`代表模块根目录
sonar.php.file.suffixes=php,module,inc

# List of the module identifiers
sonar.modules=custom_module1,custom_module2,custom_module3

# Properties can obviously be overriden for
# each module - just prefix them with the module ID
custom_module1.sonar.projectName=custom_module1
custom_module2.sonar.projectName=custom_module2
custom_module3.sonar.projectName=custom_module3

补充说明:

  • .指向当前模块的根目录,加入后SonarScanner会自动扫描每个模块根目录下所有匹配sonar.php.file.suffixes规则的文件(包括你的.module文件)
  • 原有的子目录扫描规则不受影响,依然会正常扫描inc、modules、templates下的内容

这样调整后,三个自定义模块根目录下的.module文件就能被正常纳入SonarQube的扫描范围了。

内容的提问来源于stack exchange,提问作者Santosh Jagtap

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:34:51