【问题标题】:Not able to scan file locate at root folder using sonar scanner无法使用声纳扫描仪扫描位于根文件夹的文件
【发布时间】:2018-06-01 16:03:14
【问题描述】:

我正在为我的 Drupal 项目使用 sonarqube 和 sonarqube 扫描仪。由于drupal项目是多模块项目,并且在custom_module文件夹下开发了许多自定义模块。

我只扫描文件夹 custom_module 下列出的自定义文件夹。 假设我要扫描 3 个自定义模块... custom_module1、custom_module2、custom_module3 及其下的子文件夹 inc、modules 和 templates... 我的 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

现在一切正常,它正在扫描除每个模块根目录下的 .module 文件之外的所有文件。例如custom_module1/custom_module1.module

我应该在属性文件中添加什么以使其包含 .module 文件?

【问题讨论】:

  • 这是您的完整属性文件吗?
  • @G.Ann-SonarSourceTeam 是的,这就是完整的声纳属性文件

标签: drupal-7 sonarqube sonarqube-scan


【解决方案1】:

您可以使用sonar.sources添加要扫描的文件夹

如果您想扫描所有文件sonar.sources=.

我认为您可以这样做的方法是添加点以扫描所有文件/文件夹并为排除项添加一个新行sonar.exclusions=,因此它将跳过您在排除项之后的文件夹/文件。

【讨论】:

  • 好的...我添加了“。”在源文件中,并在 sonar.exclusions 中添加了文件和文件夹。但是现在扫描仪给了我错误,比如“文件 ******** 不能被索引两次。请检查包含/排除模式是否会为主文件和测试文件产生不相交的集合”
  • 抱歉让您感到困惑,有一段时间没有使用它,也许它的工作方式是您只能将文件夹添加到其中一个,因为“。” (点)表示所有文件夹,当您将文件夹/文件添加到排除项时,它会混淆 sonarqube 尝试不使用“。” (点)在 sonar.sources 并使用文件夹/文件名代替
【解决方案2】:

我得到了上述问题的解决方案。通过为每个模块添加单独的“来源”将解决问题。

所以更新了 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.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

custom_module1.sonar.sources=inc,modules,templates,custom_module1.module
custom_module2.sonar.sources=inc,modules,templates,custom_module2.module
custom_module3.sonar.sources=inc,modules,templates,custom_module3.module

使用这个可以在根目录下添加文件。

【讨论】:

    猜你喜欢
    • 2019-07-19
    • 2017-04-27
    • 2019-03-09
    • 2018-10-03
    • 2016-12-01
    • 2019-07-02
    • 2017-08-19
    • 2018-08-30
    • 1970-01-01
    相关资源
    最近更新 更多