Sonar sources parameter for sonar cloud

I have a PHP project, and i’m trying to scope only php files. My directory structure is as


  • dir-y
    • file1.php
    • dir-a
      • filex.xml
      • file2.php
  • dir-z
    • file3.xml
    • file4.php

According to docs Analysis Scope | SonarCloud Docs I’m trying to set my -Dsonar.sources=**/*.php but it fails saying invalid source.
However this document Analysis Parameters | SonarCloud Docs says sources flag should have path to directories, both the docs quite contradict with one another?
my question is is there a way to scope files with php extension only?
my project base directory is dir-x

Hey there.

As noted in the Analysis Scope docs:

The sonar.sources parameter defines the starting point for SonarCloud to recursively search for (non-test) source code files to analyze. This parameter holds a comma-delimited list of directories (not a path matching pattern) relative to the current working directory.

If you need to use a glob pattern, set sonar.inclusions

Hi Colin, appreciate your quick response, it works well now. The analysis parameters document doesn’t list sonar.inclusion hence i wasn’t sure to use it or not. Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.