How to debug when sonar-scanner finds 0 files?

  • which versions are you using?
    The free version 7.7
  • what are you trying to achieve
    Set up my first project and a scanner for it

How to debug when sonar-scanner finds 0 files?

I’m new to SonarQube. I’m using the free version 7.7. I tried to set up a demo sonar-scanner run on some pre-existing source files, and my problem is that the scanner is finding 0 files. But there are plenty of .js files in my directory hierarchy. I’m using with settings for both sonar.projectBaseDir and sonar.sources. On the SonarQube server I’ve set the project’s Analysis Scope for Source File Inclusions of *.js. The SonarQube server Overview for my project reports all of my analysis run attempts, but it reports “This project is empty”.

I’m not seeing any way to debug this problem. The debug -X option on sonar-scanner doesn’t report which hierarchy of directories it is trying. What to try next?

This might be related to the popular “This project is empty” thread. Although in my case I have never had a non-empty project.

Here’s some interesting output from the sonar-scanner client command line:

12:00:03.651 INFO: Indexing files…
12:00:03.651 INFO: Project configuration:
12:00:03.652 INFO: Included sources: *.js
12:00:03.666 DEBUG: readpipe [git, --version],/usr/bin
12:00:03.671 DEBUG: readpipe may return ‘git version 2.17.1’
12:00:03.671 DEBUG: remaining output:

12:00:03.671 DEBUG: readpipe [git, config, --system, --edit],/usr/bin
12:00:03.674 DEBUG: readpipe may return ‘/etc/gitconfig’
12:00:03.674 DEBUG: remaining output:

12:00:03.712 DEBUG: 0 non excluded files in this Git repository
12:00:03.764 INFO: 0 files indexed
12:00:03.764 INFO: 0 files ignored because of inclusion/exclusion patterns
12:00:03.764 INFO: 0 files ignored because of scm ignore settings
12:00:03.765 INFO: ------------- Run sensors on module my_project

12:00:04.902 INFO: Calculating CPD for 0 files

Also: 14:16:25.589 DEBUG: ‘SonarJS’ skipped because there is no related file in current project

I ended up making a fresh new directory and copying some sample .js files over to it. sonar-scanner ran happily on these files, reporting things as expected. This implies that some file or other metadata in my original existing directory was making sonar-scanner drop any consideration of those valid files WITHOUT WARNING. Are you aware of anything that could do that? Maybe a pom.xml or workspace.xml ?


I can’t explain why (maybe I just didn’t search the docs enough), but by experience I can say that the correct pattern is **/*.js :wink:

INFO: Indexing files...
INFO: Project configuration:
INFO:   Included sources: *.js
INFO: 0 files indexed
INFO: Indexing files...
INFO: Project configuration:
INFO:   Included sources: **/*.js
INFO: 68 files indexed

EDIT: just for the sake of completeness, ** means “zero or more directories”.

(btw, I would remove this parameter unless you have a very good reason to use it)

Thank you! Yes, **/*.js seems to work. Another thing I had to do was, for the project, disable the SCM sensor. It was assuming an SCM system that actually isn’t present, and as a result somehow it was also causing files to be ignored.

Hi guys,

It looks like you’ve got this working, but I thought I’d mention (particularly since avoiding SCM integration had an impact) that files in your .gitignore are automatically excluded. We added this feature-not-a-bug a couple versions ago. You can turn that behavior off by passing sonar.scm.exclusions.disabled=true to your analysis.

If you don’t think this is the issue @wanaselja and you want to continue to pursue this, then it would be helpful to see your analysis properties and command line.


1 Like

Hi Ann,
Thanks for the extra clue. As an experiment, I re-enabled the SCM Sensor in the server-side project, and instead I added sonar.scm.exclusions.disabled=true to my client-side That worked, there were plenty of files analyzed.

This is not an ongoing problem for me at this time, but in case you were curious, my is:


Nothing special on the command line. Just:
sonar-scanner -X

Another point: There is no .gitignore. The source code being experimentally scanned doesn’t use git, it uses P4.