Analyze .gitignored files

  • Operating system: linux
  • IDE name and version: eclipse 24.12
  • SonarQube for Eclipse plugin version: 11.1
  • Programming language you’re coding in: Java

I have the following project layout:

myProject
|- .git
|- .gitignore // ignoring modules directory
|- src
   |- // My java code
|- modules
   |- module1
      |- .git
      |- src
         |- // some more java code 

SonarQube ignores all the files under the modules directory throwing an error "No file to analyze
". I’d like them to be analyzed. Is there a way to do so?

Hey @Asier_Lostale,

thanks for reaching out. It is correct, that the plug-in excludes all the files from the analysis because you configured it in your .gitignore as you said.

There is no way to force the plug-in to ignore our Git integration. Before creating a potential feature request for that on our side, I like to understand this situation.

My first big question mark about my head is a big Why?
Why do you ignore the code from your version control but still want to analyze it when it is not persistent?

Best,
Tobias

Hi Tobias,

In myProject/src we have the “core” code. This code can be extended by plugins which are in the modules directory (which is .gitignored). There can be many optional modules, each maintained on its own repository.

When you are developing a module you want and you want to analyze it but to compile it and run you need to have it as an eclipse project within the core code.

When working on core you don’t want modules to appear as changes in the main git repo that’s why it is ignored.

Something similar could have been accomplished with git submodules. But for historical reasons (big project with many years and several scm migrations svn → hg → git) we ended up with a .gitignore.

Thanks,

Asier

Hey @Asier_Lostale,

thank you for the information and the argumentation. When you manually analyze the file/folder inside the Eclipse project or the whole Eclipse project tho (Right click on the file -> SonarQube -> Analyze), it should analyze as you are “forcing” SonarQube for Eclipse to do so.

In your case, the Analysis is just not happening on file save. And the error message is annoying in this case, I’ll take this with me.

As you want to have an option to change the behavior of SonarQube for Eclipse in general to not take into account .gitignore files, this is more of a feature request. We will discuss it internally but this is not a priority right now,

Best,
Tobias

Hi Thobias,

Thanks for your answer and your time.

Unfortunately, your suggestion doesn’t work either. Even when I try to force SonarQube to analyze it, it continues ignoring it. This is the log I got when executing as you proposed:

Trigger: MANUAL
Analysis started with the engines being ready
For project 'sqTest' the ignore rules found by Git are: [modules/]
SonarLint processing file /sqTest/modules/m1/org/test/m1/Test2.java...
Filtered out URIs ignored by Git: file:/home/alostale/test/sq/sqTest/modules/m1/org/test/m1/Test2.java
Triggering analysis with configuration: [
  baseDir: /home/alostale/test/sq/sqTest
  extraProperties: {sonar.java.target=21, sonar.java.libraries=/home/alostale/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.6.v20250130-0529/jre/lib/jrt-fs.jar, sonar.java.enablePreview=false, sonar.java.source=21, sonar.java.binaries=/home/alostale/test/sq/sqTest/bin, sonar.scm.disabled=true, sonar.java.test.binaries=, sonar.java.test.libraries=/home/alostale/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.6.v20250130-0529/jre/lib/jrt-fs.jar,/home/alostale/test/sq/sqTest/bin}
  activeRules: [214 python, 24 css, 486 java, 46 Web, 14 xml, 155 php, 267 typescript, 29 secrets, 265 javascript]
  inputFiles: [
  ]
]

No file to analyze
Done in 12 ms

Regards,

Asier